我正在使用Twilio REST API拨打提醒电话,但我没有收到正确的CallStatus
。
当一个呼叫被忽略或没有得到回答时,我仍然在$_POST['CallStatus']
以及/2010-04-01/Accounts/XXX/Calls/XXX.json
中的状态完成,我在StatusCallback
参数中调用API请求。
以下是我的代码:
$client = new Services_Twilio($account_sid, $auth_token);
try
{
$options = array("StatusCallback" => site_url()."/callsms/endofcall/");
$call = $client->account->calls->create(
'+1xxxxxxxxxx', // From a valid Twilio number
'+1xxxxxxxxxx', // Call this number
site_url()."/callsms/call_user_xml/",
$options
);
//return $call->sid;
} catch (Exception $e) {
echo 'Error starting phone call: ' . $e->getMessage() . "\n";
}
在endofcall页面中,我写道:
$twilio_configs = $this->config->item('twilio');
$account_sid = $twilio_configs['account_sid'];
$auth_token = $twilio_configs['auth_token'];
// set URL and other appropriate options
$curl = 'https://'.$account_sid.':'.$auth_token.'@api.twilio.com/2010-04-01/Accounts/'.$account_sid.'/Calls/'.$csid.'.json';
$content = file_get_contents($curl);
$result = json_decode($content);
if($result->status=='completed')
{
//DATABASE ENTRY
}
请帮忙!
答案 0 :(得分:0)
如果通话转到语音信箱,它仍会显示为completed
。如果您没有配置语音邮件,它将仅显示为no-answer
并忽略该呼叫。