contactduty/api-client

ContactDuty Api Client

0.0.8 2018-11-06 21:26 UTC

This package is auto-updated.

Last update: 2024-09-07 16:08:49 UTC


README

ContactDuty API 客户端库允许您使用短信服务

ContactDuty 平台

使用ContactDuty API,您可以通过多部手机或物联网设备发送短信。

要求

开发者文档

https://www.contactduty.com/

安装

composer require contactduty/api-client

最后,请确保包含自动加载器

require_once '/path/to/your-project/vendor/autoload.php';

示例

// include your composer dependencies
require_once __DIR__ . '/path/to/your-project/vendor/autoload.php';

use ContactDuty\Api;

$client = new Api\ContactDutyClient([
                                        'client_id'        => '1',
                                        'client_secret'    => 'client_secret',
                                        'redirect_uri'     => 'http://www.client.com/callback'
                                    ]);
$service = new Api\Service\Sms\Service($client);

$service->messages->create(
        [
            'to' => '+0000000000', //E.164 formatted phone number - https://en.wikipedia.org/wiki/E.164
            'message' => 'api call',
            'schedule' => '2017-11-10 12:12:12', //optional
            'timezone' => 'Europe/London', //optional
            'is_recurring' => 0,  //optional - 0/1
            'recurring_type' => '', //daily/weekly/monthly required if is_recurring == 1
        ]
    );

$results = $service->messages->queued();
foreach ($results as $item) {
  echo $item['to'], "<br /> \n";
}

$results = $service->devices->all();
foreach ($results as $item) {
  echo $item['id'], "<br /> \n";
}