如何在我的网站上显示 Google Plus 平均评分?

how to display Google Plus average rating on my website?

我想在我的页面上放置 Google+ 个企业徽章。我可以使用 Google 开发者网站获取代码:https://developers.google.com/+/web/badge/#badge

但我不明白如何获得平均分数和评论数量,因此我也可以在我的网站上展示它们 - 类似于您在 search for a place:

时得到的结果

例如,这是一家餐厅的 Google+ 页面:https://plus.google.com/106659611775440325701/about?hl=en - 它清楚地显示了所有这些评论和分数。如何从 Google 获取此信息?有没有办法修改徽章的代码以包含它们?

评论数据是 Places API 的一部分。有几个选项可以让它们出现在您的网站上。

  • Maps Embed API 最简单,但需要在您的页面上加载地图。
  • 使用 Maps JS API v3 您可以在客户端加载和呈现地点详细信息。
  • 使用 HTTP API 您可以在服务器上加载详细信息以缓存在数据库中并在页面加载时呈现。

2019 年 5 月更新:现在可以使用 Place Details 拨打 API 的电话获得评论总数:https://developers.google.com/places/web-service/details#fields

截至 2019 年 1 月,它 returns user_ratings_total 字段:https://developers.google.com/maps/documentation/javascript/releases#335


所以 3 年后再看这个,我们仍然无法获得某个地方的所有评论。我们可以得到 some - 前 5 - 使用 Place Details API 调用:https://developers.google.com/places/web-service/details

然后 Google 团队有一个更改请求来扩展它:https://issuetracker.google.com/issues/35825957

最后,您可以 apply for Google Business Account and request access to extended API which allows you to get all reviews for a verified location: accounts.locations.reviews.list