我正在创建一个页面,该页面接收存储为 JSON 的信息。例如:
"PatientContactHeader":{
"PatientID":14,
"PhoneNumber":"+1558881414",
"ContactType":"Phone Call",
"DateTimeOfCall":"2015-06-25: 11:00:00AM",
"TimeZone":"EST"
} "PatientContactDetails":[
{
"MessageID":123,
"RecordingURL":"http://examplerecording.com",
"MessageTitle":"Greeting"
}
]
}
初始页面将接收此 JSON 并使用它来创建出站呼叫。根据 Twilio 的 API,出站向某个 TwiML Url 发出请求。
function initiateCall($fromNumber, $toNumber, $url) {
try {
// Initiate a new outbound call
$call = $client->account->calls->create(
$fromNumber, // The number of the phone initiating the call
$toNumber, // The number of the phone receiving call
$url, // The URL Twilio will request when the call is answered
array('IfMachine' =>'Continue')
);
echo 'Started call: ' . $call->sid;
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
我想要的是能够访问 TwiML 指令中的一些 JSON 信息。更具体地说,如果被呼叫的人应该接收多条消息,我希望能够遍历 JSON 数据并访问每条消息以进行回放。我的问题是我不知道如何将信息从发出调用请求的初始页面传递到包含 TwiML 的页面。解决此问题的合乎逻辑的方法似乎是会话变量,但我已经阅读(并发现)这些变量在进行出站呼叫时不起作用。这个问题有什么解决办法吗?