Has*_*jaz 5 php twilio twilio-php twilio-api
我正在尝试通过 twilio Api 发送批量短信。是否有任何方法可以在单个 API 请求中传递所有电话号码的数组。
Twilio 开发人员布道者在这里。
是的,现在有!它被称为passthrough API(因为它允许您通过许多不同的消息系统并发送批量消息。它是Notify API的一部分,您可以使用它来发送批量 SMS 消息。您需要设置消息服务和在您的控制台中通知服务,然后您可以使用以下代码:
<?php
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account SID and Auth Token from https://www.twilio.com/console
$accountSid = "your_account_sid";
$authToken = "your_auth_token";
// your notify service sid
$serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Initialize the client
$client = new Client($accountSid, $authToken);
// Create a notification
$notification = $client
    ->notify->services($serviceSid)
    ->notifications->create([
        "toBinding" => [
            '{"binding_type":"sms", "address":"+15555555555"}',
            '{"binding_type":"sms", "address":"+12345678912"}'
        ],
        "body" => "Hello Bob"
    ]);
查看有关使用 Notify passthrough API 发送多条消息的文档以了解所有详细信息。