简体   繁体   English

从流URL获取最后的json数据

[英]Get last json data from a streaming url

I'm using PHP curl to get JSON data from a streaming URL (an URL that keeps loading new data every 1 second without stop), when I try to open that link using PHP curl it doesn't give me any data, just a blank page ! 我正在使用PHP curl从流URL(该URL每1秒钟不断加载新数据而不会停止)获取JSON数据,当我尝试使用PHP curl打开该链接时,它不会给我任何数据,空白页 !

Can someone please help me to resolve this? 有人可以帮我解决这个问题吗? This is the link : 这是链接:

The link here 这里的链接

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "https://api.fm-track.com/object-coordinates-stream?version=1&object_id=180f2666-ea37-11e7-9869-7f695b77848b&api_key=_Xl0rjBoU2YCp0anj79eWrgKcZFDDxr4");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
preg_match_all("/:\"(.*?)\",/", $result, $matches);
$lat = $matches[1][2];
$lng = $matches[1][3];
$vitesse = $matches[1][6];
$derniersignalgps = $matches[1][1];
curl_close($ch);

You wont be able to use curl as you need to read the observable stream, not jsut the initial response. 您将无法使用curl,因为您需要读取可观察的流,而不是最初的响应。

You probably need to use stream-open or stream-read 您可能需要使用stream-openstream-read

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM