我正在尝试通过twilio Api发送批量短信。是否有任何方法可以在单个API请求中传递所有电话号码的数组。
Twilio开发人员布道者在这里。
是的,现在有!它被称为传递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"
]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句