pashamesh/comagic-api

此包最新版本(0.2.4)没有提供许可证信息。

CoMagic API 的 PHP 绑定

0.2.4 2024-09-24 14:16 UTC

README

CoMagic PHP 客户端用于

安装

要开始使用,请通过 Composer 包管理器安装包

composer require pashamesh/comagic-api

使用方法

配置

数组用于配置 Rest API 和 Call API 客户端。

$config = [
    // required for Rest API and optional for Call API
    'login' => 'put_login_here',
    'password' => 'put_password_here',
    // required for Call API if login and password not specified
    'access_token' => 'put_access_token_here',
];

如果您是 Uiscom 客户端,您需要通过指定 endpoint 来更改域名。

$config = [
    // required for Rest API and optional for Call API
    'login' => 'put_login_here',
    'password' => 'put_password_here',
    'endpoint' => [
        'rest_api' => 'https://api.uiscom.ru/api/'
    ],
    // required for Call API if login and password not specified
    'access_token' => 'put_access_token_here',
];

如果您想使用登录和密码进行 Call API 授权,请不要忘记为用户添加 Call API 权限。

Rest API

use CoMagic\RestApiClient;

$restApi = new RestApiClient($config);
var_dump(
    $restApi->call(['date_from' => '2017-01-10', 'date_till' => '2017-01-13'])
);

调用 API

API 方法名需要按照驼峰命名法指定

$callApi = new CallApiClient($config);
var_dump($callApi->listCalls());

API 请求完成后,可以获取响应元数据

var_dump($callApi->metadata());