我想在1号和2号之间进行实时对话。我的代码如下 -
<?php
require 'twilio-php-master/Twilio/autoload.php';
use Twilio\Rest\Client;
$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时,我正在通过手机拨打电话,但在试用帐户消息后手机已断开连接。请帮帮我。
答案 0 :(得分:0)
您在此处指定的网址
// Step 6: Set the URL Twilio will request when the call is answered.
需要返回一些TwiML告诉Twilio接下来要做什么。您的呼叫正在断开连接,因为Twilio已经用完了TwiML来执行。
设置您的请求网址以返回拨打其他号码的TwiML,然后运行您的第一个脚本将拨打您的电话,一旦您接听,它将拨打他们的电话并连接两个电话。