我将json数据作为post请求的一部分发送到指定的目标url,并能够获取位置url。但是来自目标url的响应是异步响应。因此,如何查找以及何时调用位置url以获得响应。下面是我获取位置url的代码。
$target_url = 'http://websieapi.com/api/messaging/post';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_HEADER, true); //include headers in http data
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$json_request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$headers = substr($result, 0, $curl_info["header_size"]); //split out header
preg_match("!\r\n(?:Location|URI): *(.*?) *\r\n!", $headers, $matches);
$location_url = $matches[1];
curl_close($ch);
现在在我的$location_url中,我已经生成了url。但我如何知道何时调用此url以获得响应。因为如果流量很大,则需要时间来生成响应。有没有办法确定是否已生成响应?任何帮助都将不胜感激。