sailthru / sailthru-php5-client
Sailthru PHP5 Client
Installs: 1 483 514
Dependents: 2
Suggesters: 0
Security: 0
Stars: 41
Watchers: 74
Forks: 46
Open Issues: 8
Requires (Dev)
- phpunit/phpunit: ~4.8
- dev-master
- 2.0.x-dev
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- dev-php-8-2-compatible
- dev-CurlErrorPatch
- dev-AddVarsToListFunctions
- dev-httpErrorHandling
- dev-RemoveEmailApi
- dev-UpdateDocs
- dev-FixTravis
- dev-develop
- dev-timeouts
- dev-SRE-3501/SRE-3502
- dev-ES-57
- dev-fix_unit_tests
- dev-bug-11634
- dev-bug-8349
- dev-bug-7196
- dev-bug-647
- dev-bug-6074
- dev-bugz-5199
- dev-diagnostics
This package is not auto-updated.
Last update: 2025-01-02 22:44:41 UTC
README
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.
Optional parameters for connection/read timeout settings
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));
API Rate Limiting
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); } }
Tests
You can run the tests locally with:
vendor/bin/phpunit