Search code examples
phpgoogle-apigoogle-my-business-api

How to get google review reply using PHP my business api?


I am using the PHP Google MyBusiness API for my application. I have business reviews.

Now I want to get any replies related to a particular review. I am able to post a reply, but I want to get replies (responses) for the review using PHP GMB API.

How do I do so?


Solution

  • see developers.google.com in the response you get reviewReply object which holds your reply

    {
      "reviewId": string,
      "reviewer": {
        object(Reviewer)
      },
      "starRating": enum(StarRating),
      "comment": string,
      "createTime": string,
      "updateTime": string,
      "reviewReply": {
        object(ReviewReply)
      },
    }
    

    more info

    to get the review use the get method of Google_Service_MyBusiness_AccountsLocationsReviews_Resource

    class Google_Service_MyBusiness_AccountsLocationsReviews_Resource extends Google_Service_Resource
    {
    
      /**
       * Returns the specified review. This operation is only valid if the specified
       * location is verified. Returns `NOT_FOUND` if the review does not exist, or
       * has been deleted. (reviews.get)
       *
       * @param string $name The name of the review to fetch.
       * @param array $optParams Optional parameters.
       * @return Google_Service_MyBusiness_Review
       */
      public function get($name, $optParams = array())
      {
        $params = array('name' => $name);
        $params = array_merge($params, $optParams);
        return $this->call('get', array($params), "Google_Service_MyBusiness_Review");
      }