Twilio拨出电话无效,它会自动终止

时间:2016-04-05 13:00:43

标签: android twilio

我们如何通过使用Twilio android sdk将应用程序调用到应用程序和应用程序。主要问题是我们的呼叫在初始化呼叫时自动终止。这是拨出呼叫的php侧脚本,但是呼出呼叫不起作用,呼叫在初始化状态时自动终止。

outgoing.php
<?php
header('Content-type: text/xml');
include 'db.php';
require 'twilio-twilio-php-788b98f/Services/Twilio.php';
require('twilio-twilio-php-788b98f/Services/Twilio/Capability.php');

$accountSid = '';
$authToken = '';
$applicationSid =''; 
// Twilio REST API version
$version = "2010-04-01";



// put a phone number you've verified with Twilio to use as a caller ID  number
$From = $_REQUEST['From'];   // Dialer Number Twilio User or Non Twilio User

// put your default Twilio Client name here, for when a phone number isn't given
$To = $_REQUEST['To'];   // Dialer Number Twilio User or Non Twilio User


$client = new Services_Twilio($accountSid, $authToken, $version);


    // Initiate a new outbound call
    $call = $client->account->calls->create(
        $From, // The number of the phone initiating the call
        $To, // The number of the phone receiving call
        'http://sitelink.coml/basic-call.php'); 
       $a= $call->sid;
?>

  basiccall.php
<Response>
<?php
    // if the From is from "client:basic" (e.g. the iOS App), redirect to the normal
    // quickstart URL to say a nice "Welcome to Twilio Client" message.
    // Otherwise, if the From is a phone number, have it call the client named "basic"
    // to dial into the iOS app.
    $from = isset($_REQUEST["From"]) ? $_REQUEST["From"] : "";
    if ( $from == "client:basic" )
    { // redirect to the sample app URL
?>
    <Say>Welcome to Twilio Client.  You have successfully made a call from your i o s application!</Say>
<?php
    }
    else if (preg_match("/^\+?\d+$/", $from)) // (zero or one '+' chars, then one or more digits)
    { // else if it's from a phone number, dial the client named "basic"
?>
    <Say>Call from Beckon Delve</Say>
    <Dial>
        <Client>basic</Client>
    </Dial>
<?php
    } 
?>
</Response>

1 个答案:

答案 0 :(得分:1)

Twilio开发者传道者在这里。

sitelink.com是您尝试构建此功能的网址吗?由于您在网址中输入了拼写错误:http://sitelink.coml/basic-call.php

否则,如果呼叫失败,则应在Monitor section of the Twilio account dashboard中记录日志。

或者,当你打电话时,你的preg_match是否与之匹配?如果它没有匹配任何内容,Twilio将获得一个空的<Response>并挂断电话。可能最好调查一下它是否也能正常工作。

抱歉,我无法准确回答您的问题。希望这会有所帮助。