sailthru/sailthru-php5-client
最新稳定版本:1.2.4
Composer 安装命令:
composer require sailthru/sailthru-php5-client
包简介
Sailthru PHP5 Client
README 文档
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
统计信息
- 总下载量: 1.65M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 40
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-09-18