尝试获取类型为 text/x-json 的响应
和 json 解码它(失败)
这是我的代码片段:
<?php
//prepare URL (in this example send WAZE web site a route calculation
$url = "http://www.waze.com/RoutingManager/routingRequest?from=x%3A-73.8876574+y%3A40.7664011+bd%3Atrue&to=x%3A-73.7721035+y%3A40.7486434+bd%3Atrue&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=2";
//send GET request to WAZE web site
$response = file_get_contents($url);
//All this isnt working
//$response = utf8_encode($response);
//$response = preg_replace("#(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|([\s\t]//.*)|(^//.*)#", '', $response);
//$response = preg_replace('/.+?({.+}).+/','$1',$response);
//go json
$responseJson = json_decode($response);
// this isnt working 2
//$responseJson = json_decode($response,true);
//now $responseJson is null :(
HELP!
?>
这是我得到的响应标头:
$http_response_header Array [6]
0 (string:15) HTTP/1.1 200 OK
1 (string:25) Content-Type: text/x-json
2 (string:35) Date: Sun, 29 Sep 2013 19:36:08 GMT
3 (string:19) Server: nginx/1.4.1
4 (string:30) X-UA-Compatible: IE=EmulateIE7
5 (string:17) Connection: Close
请帮忙
谢谢