首页 文章

如何使用Google My Business Api获取评论并回复

提问于
浏览
3

如果我有Business API的api密钥,我只想要URL的例子,比如如何放置地方id和api密钥 .

2 回答

  • 1

    如果Google已授权您使用Google Business API,那么您需要

    • 通过OAuth验证用户身份 .

    • 经过身份验证后会向您提供令牌,API会返回用户的帐户 .

    • 现在要获取评论,您必须向https://mybusiness.googleapis.com/v4/accounts/ / locations / / reviews下的 endpoints 发送Http Get请求

    您的Http Get请求必须具有访问令牌
    例如:https://mybusiness.googleapis.com/.../reviews??access_token=
    这将返回所有的评论 .
    参考:https://developers.google.com/my-business/reference/rest/v4/accounts.locations.reviews
    希望能回答你的问题 .

  • 0

    *Please note, support of v3 of the API ended on March 10, 2018; v3 will no longer be available on May 10th 2018. So we encourage you to migrate to v4.1 as soon as possible to prevent any interruption in functionality. In addition, the deprecation schedule can be found here

    You can get Google My business (GMB) reviews in same ways

    Please find the below working code for review reply with PHP HTTP request

    $access_token = "<your_access_token_here>";
    $query = array('comment' => 'Thank you for visiting our business!');
    $request_uri = "https://mybusiness.googleapis.com/v4/accounts/111050869667910417441/locations/17405754705905257334/reviews/AIe9_BFu3rdicGrPrzdyu4PDXmqMAu-9BCJf9_HF0DxzGxsjAGw5KGl1XsdqSkbsAMdl_W2XBG4bwO3wCp0_l_8KLAV7mckl5cSyJItwPqSYGiH3ktK6nrI/reply?access_token=" . $access_token;
    $curinit = curl_init($request_uri);
    curl_setopt($curinit, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curinit, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($curinit, CURLOPT_POSTFIELDS, json_encode($query));
    curl_setopt($curinit, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curinit, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/json',
      'Content-Length: ' . strlen(json_encode($query)))
    );
    $json = curl_exec($curinit);
    $phpObj = json_decode($json, true);
    var_dump($phpObj);
    

相关问题