【问题标题】:How to make call through Twilio where two people will have live conversation?如何通过 Twilio 拨打电话,让两个人进行实时对话?
【发布时间】:2017-03-31 12:13:29
【问题描述】:

我正在尝试在两个人之间建立通话,我可以拨打电话,但接听电话的人可以收听预先录制的语音邮件。我想在这两个人之间进行现场对话。我没有得到应该是什么 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();
}

有没有人可以帮助我解决这个问题。 先感谢您。等待回复。

【问题讨论】:

  • 你找到解决办法了吗?

标签: twilio twilio-api twilio-php twilio-click-to-call


【解决方案1】:

这里是 Twilio 开发者宣传员。

目前您的代码运行良好,您需要更改的是在 cmets.xml 中列为“第 6 步”的 URL。目前,该 URL 指向某个读出消息的TwiML

您需要提供一个 URL,该 URL 返回一些 TwiML,而不是阅读该消息,<Dial>s 另一个 <Number>。您会看到,当调用的第一部分连接时,Twilio 会向该 URL 发出 HTTP POST 请求以获取下一步操作的说明。

该 URL 需要在线可用,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>

让我知道这是否有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多