我们知道通过TwiML一次拨打多个号码非常容易。 注意,一旦拨打的号码中的一个接听。其余的号码会自动断开。
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Number>415-123-4567</Number>
<Number>415-321-7654</Number>
<Number>415-456-7890</Number>
</Dial>
</Response>
但是这个REST API的等效点是什么?考虑到我正在使用PHP帮助程序库。我可以这样打单号码。
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "{{ sid }}";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create("+14158675309", "+14155551212", "http://demo.twilio.com/docs/voice.xml", array());
我的猜测是我可以通过数字循环来创建单个调用。但是,当一个电话被接听时,如何断开其他号码?
答案 0 :(得分:1)
Twilio传道者在这里。
我认为,为了使用REST API创建一个同步拨号应用,您需要做的是创建一个循环,启动您想要进行的所有出站呼叫。每次开始新的呼叫时,将该呼叫的CallSid保存在某种数据存储中,如数据库。
首先会调用答案,它会对您在创建呼叫时指定的URL发出HTTP请求。在该PHP文件中,您可以遍历之前保存的CallSids列表,并使用REST API将除第一个调用Status属性之外的所有内容设置为“已完成”。这样做可以告诉Twilio挂断所有其他电话。
希望有所帮助。