leadsapiorg / gate-client
此包的最新版本(v0.3.0)没有提供许可证信息。
leadsapi.org 客户端
此包的规范存储库似乎已消失,因此包已被冻结。
v0.3.0
2020-05-25 12:40 UTC
Requires
- php: >=7.1
- ext-json: *
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- phpunit/phpunit: ^8.3
This package is auto-updated.
Last update: 2023-03-25 19:19:57 UTC
README
gate.leadsapi.org 的 PHP 客户端
安装
composer require leadsapiorg/gate-client
示例
发送短信
use Leadsapi\Gate\Client; use Leadsapi\Gate\Exception as GateException; ///////// Preparing client $client = new Client('my_username', 'my_token'); // Request credentials from your provider // If you need to change the channel: $client->setGate('test'); // If you need to set sender: $client->setSender('Main sender'); try { ///////// Single message mode $res = $client->sendSms('+13212022278', 'Hello!'); printf("SMS sent: sending id is: %d\n\n", $res->id); // Setting sender on single message level: $res = $client->sendSms('+13212022278', 'Hello!', 'Special sender'); ///////// Bulk mode $messages = [ ['+13212022278', "First hello!"], ['+12064572648', "Second\nhello!"], ['+13212022368', "Third hello!"] ]; $res = $client->sendSmsBulk($messages); printf("Bulk sent: %d messages accepted; bulk id is: %d\n", $res->enqueued, $res->id); if (!empty($res->errors)) { print("But there's some errors:\n"); foreach ($res->errors as $msg) { print("- {$msg}\n"); } } // Setting sender on bulk level: $res = $client->sendSmsBulk($messages, 'Special sender'); } catch (GateException $e) { printf("Got error: %s\n", $e->getMessage()); }