有解析json的问题

时间:2012-11-24 21:45:15

标签: php json

  

可能重复:
  Extract JSONP Resultset in PHP

    $url_address = "http://geocoder.ca/?latt=" . $lat . "&longt=" . $lon . "&reverse=1&allna=1&geoit=xml&corner=1&jsonp=1&callback=getinfo";
    $addressSet = json_decode(file_get_contents($url_address), true);

当我尝试访问$addressSet[0]时,没有任何内容

所以http://geocoder.ca/?latt=42.04&longt=-87.79&reverse=1&allna=1&geoit=xml&corner=1&jsonp=1&callback=getinfo返回数据,我该如何解析呢?

1 个答案:

答案 0 :(得分:1)

它没有返回JSON,它正在返回JSONP。不幸的是,geocoder.ca没有普通的JSON API。

真正的问题是如何使用PHP解析JSONP。请参阅this answerExtract JSONP Resultset in PHP

相关问题