classy-org/classy-php-sdk
Composer 安装命令:
composer require classy-org/classy-php-sdk
包简介
Php HTTP client library for Classy API
README 文档
README
This repository contains a php HTTP client library to let your php App interact with Classy's API.
Installation
The Classy PHP SDK can be installed with Composer:
composer require classy-org/classy-php-sdk
Be sure you included composer autoloader in your app:
require_once '/path/to/your/project/vendor/autoload.php';
Usage
Basic example
$client = new \Classy\Client([ 'client_id' => 'your_client_id', 'client_secret' => 'your_client_secret', 'version' => '2.0' // version of the API to be used ]); $session = $client->newAppSession(); // Get information regarding the campaign #1234 $campaign = $client->get('/campaigns/1234', $session); // Access the campaign goal: $campaign->goal // Unpublish the campaign $client->post('/campaign/1234/deactivate', $session);
Sessions handling
Sessions have an expiration date. It is possible to refresh a session:
if ($session->expired()) { $client->refresh($session) } // $session->expired() is now false.
Sessions are serializable, they can be saved an reused to reduce the amount of API calls:
$client = new \Classy\Client([ 'client_id' => 'your_client_id', 'client_secret' => 'your_client_secret', 'version' => '2.0' // version of the API to be used ]); // Retrieve the session from a file $session = unserialize(file_get_contents("path/to/a/cache/file")); // ... work with the API... // Save the session for later file_put_contents("path/to/a/cache/file", serialize($session));
Errors handling
This client can throw two types of Exceptions:
- Classy\Exceptions\SDKException when the SDK is misused
- Classy\Exceptions\APIResponseException when the API is not returning an OK response
try { $response = $client->get('/endpoint', $session); } catch (\Classy\Exceptions\APIResponseException $e) { // Get the HTTP response code $code = $e->getCode(); // Get the response content $content = $e->getResponseData(); // Get the response headers $headers = $e->getResponseHeaders(); }
classy-org/classy-php-sdk 适用场景与选型建议
classy-org/classy-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.8k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2016 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 classy-org/classy-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 classy-org/classy-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 18.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-04-19