I want to immediately terminate a call as soon as the call is initialized an the user gets one ring
this are my routes
Route::any('missedCall','RegistrationController@missedCall');
Route::any('callForMissedCall',function(){
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"? ><Response/>');
$xml->addChild('Dial timeout="0"');
$header['Content-Type'] = 'application/xml';
return Response::make($xml->asXML(), '200', $header);
});
and the function that I am calling with the first route
public function missedCall(Request $request)
{
$data = $request->all();
if (isset($data['id'])) {
Response::json(array("status"=>'failure',"msg"=>'Missing argument'));
}
$regDetails = RegistrationDetails::find($data['id']);
if (!$regDetails)
return Response::json(array("status"=>"failure","msg"=>"No data is present"));
$phone_no = $regDetails->phone_no;
$country = $regDetails->country;
if (!$country)
return Response::json(array("status"=>"failure","msg"=>"Country missing"));
$countryData = Country::where('name',"LIKE",$country)->first();
$phnCode = $countryData->phonecode;
$phone = "+".$phnCode.$phone_no;
$twilio = Twilio::call($phone, $_ENV['app_url']."/callForMissedCall");
}
The above code only terminates after the user picks the call. Any solution around this.. Thanks in advance
2
Answers
Following this link from twillio https://www.twilio.com/docs/api/twiml/dial
I was able to implement the calling.. It is not quite possible to terminate the call but one can follow my code to see how i was able to achieve this
on the xml part of it
});
Twilio evangelist here.
We just introduced a new feature called Call Progress Events which gives you more granular notifications as a call progresses. I’m not sure we can let you know that a call made exactly one ring, but I know we can tell you that it is “ringing” vs “answered”.
If you detect “ringing” you could subsequently terminate the call.
hope that helps.