cloudycity / uc-marketing-sdk
UC MarketingAPI SDK
v0.3
2020-03-31 06:21 UTC
Requires
- php: >=5.6.0
- doctrine/collections: ~1.3
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-19 22:41:31 UTC
README
安装
composer require cloudycity/uc-marketing-sdk:*
环境要求
- PHP 5.6 +
使用
use CloudyCity\UCMarketingSDK\Client; use CloudyCity\UCMarketingSDK\Kernel\Contracts\UcService; $accounts = UcService::getAccounts(); // 仅提供Interface,需自行实现 // 遍历广告账号 foreach ($accounts as $account) { // 第四个参数为可选参数,默认为数组,客户端会自动将响应转为该格式,下载报表的csv文件也会自动转换成该格式 // 支持的格式有: array、object、collection、raw、实现\CloudyCity\UCMarketingSDK\Kernel\Contracts\Arrayable的自定义类 $client = new Client($account['username'], $account['password'], $account['token']); try { $result = $client->account->get(); } catch (\CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException $e) { // 阿里汇川接口未提示成功 } catch (\CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException $e) { // 实例化客户端时配置的响应格式有误 } catch (\GuzzleHttp\Exception\GuzzleException $e) { // Guzzle工具请求异常 } }
方法
License
MIT