【发布时间】:2017-10-06 18:04:24
【问题描述】:
我想在 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 时,我在手机上接到电话,但在试用帐户消息后手机断开连接。请帮帮我。
【问题讨论】:
-
我认为您不需要在 TwiML 中再次拨打电话(拨号),因为它已经拨打了该号码。相反,您需要告诉它要做什么,例如播放问候语或录制一些东西。见twilio.com/docs/quickstart/php/rest/initiating-calls
-
没有拨号仍然无法进行实时通话。我可以播放音频但不能进行实时对话
-
我只想在两个人之间进行实时对话
标签: twilio twilio-php twilio-click-to-call twilio-functions