2 回答
TA贡献2037条经验 获得超6个赞
对我来说很好。
$url = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?key=APIKEY&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry,reference,place_id&input=Lollapalooza+Argentina+Mart%C3%ADnez+Argentina";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
print '<pre>';
print $response;
print '</pre>';
哪个打印:
{
"candidates" : [
{
"formatted_address" : "Martínez, Buenos Aires Province, Argentina",
"geometry" : {
"location" : {
"lat" : -34.4811677,
"lng" : -58.5165812
},
"viewport" : {
"northeast" : {
"lat" : -34.47967187010728,
"lng" : -58.5156313
},
"southwest" : {
"lat" : -34.48237152989272,
"lng" : -58.51943089999999
}
}
},
"name" : "Lollapalooza Argentina",
"photos" : [
{
"height" : 1536,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/115749286027841945795\"\u003eA Google User\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAiIyTEnkgKjKYFyQZKesopF4_dwAP6h0ynKq0nO5e9AelAo9D0IPqASptGAbZ999ZcOfPIQnlQYie5KtO45bIkSAMOowBkROYcJLdntbS0WhsNhhQJaG5lxU8aCUTuyjGEhBnHL_HnTImzwkwS4OHVSN9GhRO_IGFKamDj_8OEIL3i9MGaCWsXQ",
"width" : 2048
}
],
"place_id" : "ChIJg-5cj9SxvJURkm6B2DlkKL0",
"rating" : 5,
"reference" : "ChIJg-5cj9SxvJURkm6B2DlkKL0"
},
{
"formatted_address" : "Av. Sta Fe 1, B1642 Martínez, Buenos Aires, Argentina",
"geometry" : {
"location" : {
"lat" : -34.4742948,
"lng" : -58.51265829999999
},
"viewport" : {
"northeast" : {
"lat" : -34.47292497010727,
"lng" : -58.51127897010728
},
"southwest" : {
"lat" : -34.47562462989271,
"lng" : -58.51397862989273
}
}
},
"name" : "Lollapalooza Argentina",
"place_id" : "ChIJUQmrWaqxvJURScOzSiIIk9o",
"rating" : 0,
"reference" : "ChIJUQmrWaqxvJURScOzSiIIk9o"
}
],
"status" : "OK"
}
TA贡献1951条经验 获得超3个赞
您面临的问题是由于执行请求的原始计算机的 IP 地址不同。
为了证明这一点,从 IP 偏差更改为区域,两个机器/浏览器/php 脚本应该返回相同的数据集。
看更多:
locationbias - 通过指定半径加上 lat/lng 或表示矩形点的两个 lat/lng 对,首选指定区域的结果。如果不指定该参数,则API默认使用IP地址偏置。
IP 偏差:指示 API 使用 IP 地址偏差。传递字符串 ipbias(此选项没有附加参数)。
来源:https ://developers.google.com/places/web-service/search
- 2 回答
- 0 关注
- 380 浏览
添加回答
举报