我让Twilio开始,暂停,恢复和停止正在进行的入站呼叫的记录。但是,当我使用相同的方法,相同的代码来记录进行中的出站呼叫时,会出现const AppNavigator = StackNavigator(SomeAppRouteConfigs);
class App extends React.Component {
someEvent() {
// call navigate for AppNavigator here:
this.navigator && this.navigator.dispatch({ type: 'Navigate', routeName, params });
}
render() {
return (
<AppNavigator ref={nav => { this.navigator = nav; }} />
);
}
错误。
我知道我可以使用20404
动词从头开始记录呼出电话,但是我需要能够选择性地记录正在进行的呼出电话。
正如我所说的,我可以使用它来记录正在进行的入站呼叫,因此我对为什么相同的方法不适用于正在进行的出站呼叫感到困惑。
这是我用来启动通话录音的javascript:
<record>
ajax在我的php(Laravel)中调用此方法:
document.getElementById('button-record-start').onclick = function () {
var call_id = $('#call-id').val();
var csrf_token = $('meta[name="csrf-token"]').attr('content');
console.log(call_id);
console.log(csrf_token);
$.ajax({
url: 'https://my-url.ngrok.io/twilio/recording/start',
type: 'POST',
headers: {
'X-CSRF-TOKEN': csrf_token
},
data: {
call_id: call_id
},
dataType: 'JSON',
success: function (data) {
$('#recording-id').val(data.sid);
console.log(data);
},
error: function(xhr, status, error) {
console.log('error:');
console.log(xhr);
}
});
};
方法public $twilio_api_base_url = 'https://api.twilio.com/2010-04-01/Accounts/';
public function start(Request $request)
{
$call_id = $request->input('call_id');
$url = $this->twilio_api_base_url . env('TWILIO_ACCOUNT_SID');
$url .= '/Calls/' . $call_id . '/Recordings.json';
$params = [ 'RecordingStatusCallback'=>'https://myapp.com/recording-events',
'RecordingStatusCallbackEvent' => 'in-progress'
];
$this->send_request_to_twilio($url, $params);
}
如下所示:
send_request_to_twilio
public static function send_request_to_twilio($url, $params)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_USERPWD, env('TWILIO_ACCOUNT_SID') . ':' . env('TWILIO_AUTH_TOKEN') );
curl_exec($ch);
curl_close($ch);
}
的公式正确。我唯一能想到的是,也许Twilio在完成强制录音后告诉$url
时我正在试用帐户中,告诉我我正在试用帐户中,然后发起实际通话。它是否正确?如果是这样,一旦发生新的ID,我将如何查找?
添加此内容以显示如何获得呼叫sid:
CallSid
这就是getJSON调用的我的$.getJSON('twilio/token')
.then(function (data) {
device = new Twilio.Device(data.token);
device.on('ready',function (device) {
console.log('device.on ready')
});
device.on('error', function (error) {
console.log('device.on error');
});
device.on('connect', function (conn) {
console.log('device.on connect');
var twilio_call_sid = conn.parameters.CallSid;
log_call_to_database(twilio_call_sid, 'connect');
});
// other stuff
});
的样子:
twilio/token