Reputation: 720
Iam using twilio Programmable voice while trying to Tracking the call status of an outbound call and save it log whether the user answer or cut the call ,but the problem i didn't get any log and while checking in twilio debugger it showing error:15003
Here my Code:
<?php
require_once "vendor/autoload.php";
use Twilio\Rest\Client;
$AccountSid= 'AC04421826f5ffaa58eaefa1ba6984dac2';
$AuthToken= 'token';
$client = new Client($AccountSid, $AuthToken);
try {
$call = $client->account->calls->create(
// to call.
"+9120000000",
"+1209000001",
array(
"url" => "http://demo.twilio.com/docs/voice.xml",
"method" => "GET",
"statusCallbackMethod" => "POST",
"statusCallback" => "localhost/twilio/log.txt",
"statusCallbackEvent" => array(
"initiated", "ringing", "answered", "completed"
)
)
);
echo "Started call: " . $call->sid;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
Upvotes: 0
Views: 3010
Reputation: 186
The issue here is a GET or POST request cannot be written directly to log.txt file and the file should be hosted on a http domain.
change the following code
"statusCallback" => "localhost/twilio/log.txt",
to
"statusCallback" => "http://yourdomain.com/twilio/log.php",
as you rather need an additional file log.php which can write to log.txt
<?php
$status = implode(',',$_REQUEST) ;
$handle = fopen('log.txt','a');
fwrite($handle, $status);
?>
Upvotes: 0
Reputation: 10366
Twilio evangelist here.
Looks like you have set the statuscallback property to point to localhost
.
localhost
is a domain that is only reachable from your own local machine so Twilio does not how to reach the localhost
running on your local machine.
I'd suggest checking out ngrok which is a simple tool that lets you expose the web server running on your local machine via a publicly addressable domain.
Hope that helps
Upvotes: 1