0
我正在使用Twilio REST API發出提醒呼叫,但我沒有得到正確的CallStatus
。在發佈參數和StatusCallback中的呼叫狀態不正確
當呼叫被忽略或未收到應答時,我仍在完成$_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
}
請幫幫忙!