-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Hi there,
I'm Joseph B. web developer, I developed a web apps using the this php sdk(sparkapi). I was very happy to the result, I got what I want however there's an issue I encountered that I cannot able to fix. I encountered error code 1550 which is over rate limit, I debugged my codes and I found out that every time I make a request to flex it's also requesting a new access token which is not supposed to be. I checked the database and I noticed every time I make a request the SparkAPI_authtoken value was changing which is not suppose to be I think? I was wondering if this issue is related to SDK itself or just in my codes. For more info I posted my codes and my email I've send to flex support below.
For your reference
Here's my last email to flex support
Hi Don,
Thank you very much for your help. I almost got your point but I need few more clarification.
For your information here's what my codes does. I created a main controller class and a listings class, the listings class extends to main controller class. Inside the main controller class I have the flex_connect function this function will do the api auth connection and I call this functions every time the listings class was initiated and I think this was causing the over limit of authentication request.
In every search query the listings class was called and of course the flex_connect method too because it was placed in the _construct method of listings class. I was wondering though if there's a way to check the last session created and used it instead of requesting a new one? Please advice, I want know if the PHP SDK you've provided has this already if they don't have I have no choice to one.
MAIN CONTROLLER CLASS
class main_controller_class{
function flex_connect(){
$api = new SparkAPI_APIAuth($this->api_key, $this->api_secret);
$api->SetApplicationName("PHP-API-Code-Examples/1.0");
$api->SetCache( new SparkAPI_MySQLiCache($this->db_host, $this->db_name, $this->db_user, $this->db_pass, 'api_cache'));
$result = $api->Authenticate();
if ($result === false) {
echo "API Error Code: {$api->last_error_code}<br>\n";
echo "API Error Message: {$api->last_error_mess}<br>\n";
exit;
}
}
return $api;
}
LISTINGS CLASS
class listings_class extends main_controller_class{
function __construct(){
$this->api = $this->flex_connect();
}
}
Thank you in advance for your help. :)