classy-org/constantcontact-php-client
Composer 安装命令:
composer require classy-org/constantcontact-php-client
包简介
Wrapper around Guzzle Http Client to interact with Constant Contact APIv2
README 文档
README
Wrapper around Guzzle Http Client to interact with Constant Contact APIv2
Installation
The ConstantContact API php client can be installed with Composer:
composer require classy-org/constantcontact-php-client
Be sure you included composer autoloader in your app:
require_once '/path/to/your/project/vendor/autoload.php';
Usage
// Instantiate the client $client = new \Classy\ConstantContactClient('API-KEY', 'ACCESS-TOKEN'); // Make a request. $httpResponse = $client->request('GET', 'contacts'); $contacts = json_decode($httpResponse->getBody()->getContents()); //Or Grab Data Quickly. $contacts = $client->getData('contacts'); //Store a Contact Quickly. $payload = [ 'lists' => [ [ 'id' => (string)1 ] ], 'email_addresses' => [ [ 'email_address' => (string)'person@constantcontact.com' ] ], 'first_name' => (string)'My', 'last_name' => (string)'Name', ]; $contacts = $client->addContact($payload);
Exception handling
This client is using Guzzle Http client. Exceptions are thrown when the Http response is not a 200 (OK) one:
try { $response = $client->request('POST', 'path/to/route', ['body' => ['check' => 1]]); } catch (Exception $e) { if ($e instanceof \GuzzleHttp\Exception\ConnectException) { // there was a networking error } if ($e instanceof \GuzzleHttp\Exception\ClientException) { // Mailchimp API returned a 4xx response. $httpStatusCode = $e->getCode(); if ($httpStatusCode == 404) { // resource doesn't exist } if ($httpStatusCode == 401) { // you're unauthorized (api key must be invalid) } if ($httpStatusCode == 403) { // you're not allowed to request this endpoint } if ($httpStatusCode == 400) { // body payload is invalid } if (...) { // } $bodyResponse = $e->getResponse()->getBody()->getContents(); } if ($e instanceof \GuzzleHttp\Exception\ServerException) { // ConstantContact returned a 5xx response, which means they experience technical difficulties. } }
classy-org/constantcontact-php-client 适用场景与选型建议
classy-org/constantcontact-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24.68k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 classy-org/constantcontact-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 classy-org/constantcontact-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 24.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-04-26