【问题标题】:Google My Business API to fetch ReviewsGoogle My Business API 以获取评论
【发布时间】:2018-07-17 18:00:05
【问题描述】:

我想知道如何使用 GMB API 来获取评论。根据谷歌文档,我们必须向https://mybusiness.googleapis.com/v3/{name=accounts/*/locations/*}/reviews发出GET请求

但是{name=accounts/*/locations/*} 是什么意思,我们可以从哪里获得帐户和位置的价值。

这也需要 OAuth 2.0。如果我得到一个 access_token,那么 GET 请求将是这样的:- https://mybusiness.googleapis.com/v3/{name=accounts/*/locations/*}/reviews?access_token=token

这很令人困惑。谁能告诉我如何正确使用 GMB API 来获取谷歌评论。

【问题讨论】:

  • 您是否阅读过Google 网站上与My Business API 相关的所有文档
  • 您找到解决方案了吗? @puneet

标签: c# google-my-business-api


【解决方案1】:

但是 {name=accounts//locations/} 是什么意思,我们可以从哪里获得帐户和位置的价值。

要获取此详细信息,请先使用以下 API (https://mybusiness.googleapis.com/v4/accounts?access_token=#####) 获取帐户

获得帐户列表后,在此 API 的响应中使用以下 API (https://mybusiness.googleapis.com/v3/" + name + "/locations) 获取帐户位置列表,您将获得 {name=accounts/*/locations/*}

这也需要 OAuth 2.0。如果我得到一个 access_token,那么 GET 请求将是这样的:https://mybusiness.googleapis.com/v3/{name=accounts/*/locations/*}/reviews?access_token=token

是的,没错。

让我知道这项工作是否适合你。

【讨论】:

    【解决方案2】:

    使用 Google OAuth 2 Playground 用于测试 Google 评论的获取

    1. 创建项目
      • Console.cloud.google.com
      • 以 {projectowner}@google.com 身份登录
      • 从标题的下拉列表中选择一个项目或单击新建项目
    2. 转到左侧菜单中的 API 和服务
    3. 启用 Google 我的商家 API;这需要 Google 进行验证,可能需要几天时间。他们会向您发送电子邮件。
    4. 转到developers.google.com/oauthplayground
    5. 使用设置工具,将 OAuth 流程设置为客户端,然后点击使用您自己的 OAuth 凭据
    6. 从 console.developers.google.com/apis 获取客户端 ID 并将其粘贴到
    7. 将此纳入范围:https://www.googleapis.com/auth/plus.business.manage 并通过 {projectowner}@gmail.com 进行授权
    8. 交换令牌的验证码
    9. 获取帐户名称:
    10. 要获取位置名称:
      • 将请求 URI 设置为 https://mybusiness.googleapis.com/v4/accounts/{paste account name here}/locations 其中 {paste ... here} 是您复制的帐户名称
      • 返回的 JSON 包含您的所有位置
      • 将包含引号和逗号的位置名称复制到临时保存文件;下一步将在 JSON 数组中使用它们
    11. 获取多个位置的评论 一种。将 Request URI 设置为 https://mybusiness.googleapis.com/v4/accounts/{account name here}/locations:batchGetReviews 和 Method to Post 湾。将请求正文设置为 { “位置名称”:[ "accounts/999999999999999999999/locations/88888888888888888888", "accounts/999999999999999999999/locations/77777777777777777777", . . . “帐户/999999999999999999999/locations/11111111111111111111” ], “页面大小”:200, "orderBy": "updateTime desc", “ignoreRatingOnlyReviews”:假 }

    使用您从位置 JSON 中为数组的每一行保存的帐户名称

    1. 如果您的评论总数超过 200 条,则必须将“pageToken”:字符串添加到 JSON 正文中,其中字符串是前面 POST 中返回的值。

    【讨论】:

    • 为什么我的权限被拒绝了?由于权限被拒绝,我遵循了所有内容并在第 9 步堆叠
    • 当您在 OAuth 2.0 Playground 中时,您是否将 googleapis.com/auth/plus.business.manage 放入范围并按 ENTER,然后单击 Authorize APIs?粘贴 URI 后,您必须按 Enter 才能启用授权按钮。
    • 尝试使用此端点 https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/localPosts 创建帖子,它返回给我一个 Requested entity was not found. 任何建议?
    • 您是否复制了第 9 步中返回的“name:”值并将其粘贴到 URI 中以代替 {account name here}? [link](mybusiness.googleapis.com/v4/accounts{account name here}/locations:batchGetReviews) 另外,您需要将 body 设置为 { "locationNames": [ "accounts/999999999999999999999/locations/88888888888888888888", "accounts/999999999999999999999/locations/77777777777777777777", . . . "accounts/999999999999999999999/locations/11111111111111111111" ], "pageSize": 200, "orderBy": "updateTime desc", "ignoreRatingOnlyReviews": false },用您的数字替换。
    • 我只使用account_name/8123127先生的账号
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-08
    相关资源
    最近更新 更多