我想在数字 1 和数字 2 之间进行实时对话。我的代码如下 -
<?php
require 'twilio-php-master/Twilio/autoload.php';
use TwilioRestClient;
$sid = "******************";
$token = "***************";
$client = new Client($sid, $token);
try {
// Initiate a new outbound call
$call = $client->account->calls->create(
// Step 4: Change the 'To' number below to whatever number you'd like
// to call.
"Number 2",
// Step 5: Change the 'From' number below to be a valid Twilio number
// that you've purchased or verified with Twilio.
"Number 1",
// Step 6: Set the URL Twilio will request when the call is answered.
array("url" => "twiml_url")
);
echo "Started call: " . $call->sid;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
?>
我的 twiML 如下 -
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="Number 1">
<Number>Number 2</Number>
</Dial>
</Response>
当我在浏览器中点击此 REST API 时,我的手机接到电话,但在试用帐户消息后手机断开连接。请帮助我。
您
在此处指定的网址
// Step 6: Set the URL Twilio will request when the call is answered.
需要返回一些 TwiML 来告诉 Twilio 下一步该做什么。您的呼叫正在断开连接,因为 Twilio 已用完要执行的 TwiML。
设置您的请求 URL 以返回 TwiML,该 TwiML 会呼叫不同的号码,然后运行您的第一个脚本将呼叫您的电话,一旦您拿起它将呼叫他们的电话并连接两个呼叫。