PHP code example of sailthru / sailthru-php5-client
1. Go to this page and download the library: Download sailthru/sailthru-php5-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sailthru / sailthru-php5-client example snippets
// 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);
}
}