Man*_*Rao 13 php google-maps google-maps-api-3
我使用Google Maps API获取公司的评论和评分.
第1步:HTTP请求获取引用ID.
$url = 'https://maps.googleapis.com/maps/api/place/textsearch/json?query='.<CompanyName>.'&sensor=true&key='.<apikey>;
Run Code Online (Sandbox Code Playgroud)
在HTTP请求之后,我得到了业务的referenceId.
第2步:HTTP请求获取评论.
$url = 'https://maps.googleapis.com/maps/api/place/details/json?reference='.<referenceId>.'&key='.<apiKey>
Run Code Online (Sandbox Code Playgroud)
有了上述内容,我得到了"最有帮助的评论"和最多5条评论.
所以我希望获得所有评论或最新评论.我需要添加参数吗?
使用位置的 place_id 获取最后 5 次回访的其他简单方法(您可以在这里找到它:https : //developers.google.com/places/place-id)
$url = "https://maps.googleapis.com/maps/api/place/details/json?key=Yourkey&placeid=YourplaceID";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
$res = json_decode($result,true);
$reviews = $res['result']['reviews'];
Run Code Online (Sandbox Code Playgroud)
如果您想获得所有评论,则需要使用Google My Business API.
这是另一个不同的API,您应该从Google请求该地点的财产.
https://developers.google.com/my-business/content/review-data#list_all_reviews
| 归档时间: |
|
| 查看次数: |
21751 次 |
| 最近记录: |