我正在设置两个人之间的通话,我可以拨打电话,但是接听电话的人可以收听预先录制的语音邮件。我想在这两个人之间进行实时对话。我没有得到URL应该是什么以及如何设置它。
我的示例PHP代码是 -
require_once "application/helpers/Services/twilio-php-master/Twilio/autoload.php";
use Twilio\Rest\Client;
// Step 2: Set our AccountSid and AuthToken from https://twilio.com/console
$AccountSid = "Axxxxxxxxxxxxxxxxxxxxxc0";
$AuthToken = "xxxxxxxxxxxxxxxxxxxxxxxxx";
// Step 3: Instantiate a new Twilio Rest Client
$client = new Client($AccountSid, $AuthToken);
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.
"+91my_number",
//$_POST['to'],
// Step 5: Change the 'From' number below to be a valid Twilio number
// that you've purchased or verified with Twilio.
"+1_twilioverified_number",
// Step 6: Set the URL Twilio will request when the call is answered.
array("url" => "http://demo.twilio.com/welcome/voice/")
);
echo "Started call: " . $call->sid;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
有没有人可以帮助我解决这个问题。 先感谢您。等待回复。
答案 0 :(得分:2)
Twilio开发者传道者在这里。
目前您的代码工作正常,您需要更改的内容是列为&#34的网址;步骤6"在评论中。目前,该网址指向一些用于读取消息的TwiML。
您需要提供一个返回某个<Dial>
s另一个<Number>
的TwiML的网址,而不是阅读该消息。您可以看到,当呼叫的第一部分连接时,Twilio向该URL发出HTTP POST请求,以获取下一步操作的说明。
此网址需要在线提供给Twilio才能发出HTTP请求。您可以将此TwiML部署到您的服务器,使用Twilio控制台中的TwiML Bin或本地开发计算机上的test it out using ngrok。
你想要的TwiML应该看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Number>YOUR_NUMBER_HERE</Number>
</Dial>
</Response>
让我知道这是否有帮助。