API可以从Google获取所有评论和评级

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条评论.

所以我希望获得所有评论或最新评论.我需要添加参数吗?

Dor*_*ian 9

使用位置的 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)


Net*_*ous 7

如果您想获得所有评论,则需要使用Google My Business API.

这是另一个不同的API,您应该从Google请求该地点的财产.

https://developers.google.com/my-business/content/review-data#list_all_reviews

  • 实际上,我想要任何公司的所有评论和评级,而不是单个公司。 (4认同)
  • 对于地图 API,我很遗憾地告诉您这是不可能的。检查我在上一条评论中放置的 API 链接。它说“评论[] 最多包含五个评论的 JSON 数组” (3认同)