我们如何使用 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>
最佳答案
此处为 Twilio 开发人员布道师。
sitelink.com 是您尝试为其构建此功能的网址吗?由于您在 URL 中有错字:http://sitelink.coml/basic-call.php
否则,如果调用失败,Monitor section of the Twilio account dashboard 中应该有日志.
或者,是您的 preg_match
打电话时不匹配任何东西?如果它不匹配任何东西,Twilio 将得到一个空的 <Response>
。并挂断电话。可能最好调查一下它是否也正常工作。
抱歉,我无法准确回答您的问题。希望这有帮助。
关于android - Twilio 拨出电话不工作,它自动终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36427117/