Reputation: 191
How we can call app to app and app to phone by using Twilio android sdk. The main problem is that our call is terminated automatically when call is initialized.This is the php side script for outgoing calls , but outgoing call is not working, call terminated automatically when in intialized state.
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>
Upvotes: 1
Views: 719
Reputation: 73029
Twilio developer evangelist here.
Is sitelink.com the URL you are trying to build this feature for? As you have a typo in the URL: http://sitelink.coml/basic-call.php
Otherwise, if the call is failing, there should be logs in the Monitor section of the Twilio account dashboard.
Alternatively, is your preg_match
not matching anything when you call? If it doesn't match anything, Twilio will just get an empty <Response>
and hang up the call. Probably best to look into whether that is working correctly too.
Sorry I can't answer your question exactly. Hope this helps though.
Upvotes: 1