【发布时间】:2017-06-01 06:55:36
【问题描述】:
当我从浏览器获取 Google Maps Geocoding API 时,它可以正常工作,但不能从我的 PHP 脚本中获取。
返回:
{
"results" : [
{
"address_components" : [
{
"long_name" : "La Pérelle",
"short_name" : "La Pérelle",
"types" : [ "colloquial_area", "political" ]
},
],
"formatted_address" : "La Pérelle, 38380, France",
// other stuffs
"partial_match" : true,
"place_id" : "ChIJZzDRRAX4ikcRnZ-vb1tnTgY",
"types" : [ "colloquial_area", "political" ]
}
],
"status" : "OK"
}
不工作:
<?php
$url = 'https://maps.google.com/maps/api/geocode/json?sensor=false&key=AIzaSyDqIj_SXTf5Z5DgE_cvn5VF9h5NbuaiCbs&address=La%20P%C3%A9relle,%20Saint-Pierre-de-Chartreuse,%20France';
echo file_get_contents($url);
返回:
{
"results" : [],
"status" : "ZERO_RESULTS"
}
有什么想法吗?
更新:有些人也没有从他们的浏览器中看到任何结果。 Google 可以利用我的职位来展示不错的结果吗?
【问题讨论】:
-
你确定它有效吗?我的结果为零。
-
在您的浏览器中?它现在对我有用。
-
请求的结果为零。只需在浏览器或 curl 上单击您的链接。
标签: php google-maps google-geocoding-api