我希望在初始化呼叫后立即终止呼叫,用户获得一个响铃
这是我的路线
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);
});
以及我用第一条路线呼叫的功能
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");
}
以上代码仅在用户选择呼叫后终止。解决这个问题的任何解决方案..提前致谢
答案 0 :(得分:0)
点击此链接来自twillio https://www.twilio.com/docs/api/twiml/dial
我能够实现调用..终止调用是不可能的,但是可以按照我的代码来看看我是如何实现这个的
public function missedCall($id)
{
if (isset($id)) {
Response::json(array("status"=>'failure',"msg"=>'Missing argument'));
}
$regDetails = RegistrationDetails::find($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");
}
在xml部分
Route::any('callForMissedCall',function(){
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Response/>');
$xml->addChild('Dial');
$header['Content-Type'] = 'application/xml';
return Response::make($xml->asXML(), '200', $header);
});
答案 1 :(得分:0)
Twilio传道者在这里。
我们刚刚推出了一项名为Call Progress Events的新功能,可在呼叫过程中为您提供更精细的通知。我不确定我们是否能让你知道一个电话只打了一个铃声,但我知道我们可以告诉你它已经响了#34; vs&#34;回答&#34;。
如果您发现&#34;响铃&#34;你随后可以终止通话。
希望有所帮助。