For installation instructions, documentation, and examples please visit: http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/php5
A simple client library to remotely access the Sailthru REST API
as per http://getstarted.sailthru.com/developers/api
By default, it will make request in JSON
format.
Increase timeout from 10 (default) to 30 seconds.
$client = new Sailthru_Client($this->api_key, $this->secret, $this->api_url, array('timeout' => 30000, 'connect_timeout' => 30000));
Here is an example how to check rate limiting and throttle API calls based on that. For more information about Rate Limiting, see Sailthru Documentation
// get last rate limit info
$rate_limit_info = $sailthru_client->getLastRateLimitInfo("user", "POST");
// getRateLimitInfo returns null if given endpoint/method wasn't triggered previously
if ($rate_limit_info) {
$limit = $rate_limit_info['limit'];
$remaining = $rate_limit_info['remaining'];
$reset_timestamp = $rate_limit_info['reset'];
// throttle api calls based on last rate limit info
if ($remaining <= 0) {
$seconds_till_reset = $reset_timestamp - time();
// sleep or perform other business logic before next user api call
sleep($seconds_till_reset);
}
}
You can run the tests locally with:
vendor/bin/phpunit