sinat_32635107
sinat_32635107
2016-04-04 02:12
采纳率: 60%
浏览 5.2k
已采纳

PHP CURL 获取高德web API 时返回不全

我直接使用地址栏返回的内容是这样的:
{"status":"1","info":"OK","infocode":"10000","count":"1","geocodes":[{"formatted_address":"北京市朝阳区阜通东大街|6号","province":"北京市","citycode":"010","city":"北京市","district":"朝阳区","township":[],"neighborhood":{"name":[],"type":[]},"building":{"name":[],"type":[]},"adcode":"110105","street":[],"number":[],"location":"116.481229,39.990400","level":"门牌号"}]}
但使用php CRUL 返回的只有:{"status":"1","info":"OK","infocode":"10000","count":"0","geocodes":[]}
geocodes里面的内容没有
这是我的php后台代码片段
$requesturl="http://restapi.amap.com/v3/geocode/geo?address=北京市朝阳区阜通东大街6号&output=json&key=8ca8e28cdd92fed465d899e4798cff39";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $requesturl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$info=curl_exec($ch);
curl_close($ch);
echo json_decode($info, true);

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • u012228558
    龙之末图 2016-04-05 05:57
    已采纳

    你的代码没有问题,可以运行并获得数据,应该是你的文件编码格式出错了,你看看你的文件是不是gbk的

    点赞 评论
  • oyljerry
    oyljerry 2016-04-05 02:03

    看看是不是user agent等没有配置好 先看看浏览器发送请求提交了哪些数据 尤其httpheader

    点赞 评论

相关推荐