समीक्षा के डेटा के साथ काम करना

इस ट्यूटोरियल में, किसी समीक्षा को लिस्ट करने, वापस पाने, उसका जवाब देने, और उसे मिटाने का तरीका बताया गया है. Google My Business API की मदद से, समीक्षा के डेटा का इस्तेमाल करके ये काम किए जा सकते हैं:

शुरू करने से पहले

Google My Business API का इस्तेमाल करने से पहले, आपको अपना ऐप्लिकेशन रजिस्टर करना होगा. साथ ही, OAuth 2.0 क्रेडेंशियल पाने होंगे. Google My Business API का इस्तेमाल शुरू करने के तरीके के बारे में जानने के लिए, बुनियादी सेटअप देखें .

सभी समीक्षाएं लिस्ट करना

एक साथ कई समीक्षाओं की ऑडिट करने के लिए, किसी जगह की सभी समीक्षाएं लिस्ट करें. किसी जगह से जुड़ी सभी समीक्षाएं वापस पाने के लिए, accounts.locations.reviews.list API का इस्तेमाल करें.

किसी जगह से जुड़ी सभी समीक्षाएं वापस पाने के लिए, यह तरीका अपनाएं:

HTTP
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews
Java

यहां दिया गया फ़ंक्शन, Mybusiness.Accounts.Locations.Reviews.List का इस्तेमाल करता है.

/**
 * Returns a list of reviews.
 * @param locationName Name of the location to retrieve reviews for.
 * @return List<Reviews> A list of reviews.
 * @throws Exception
 */
public static List<Review> listReviews(String locationName) throws Exception {
  Mybusiness.Accounts.Locations.Reviews.List reviewsList =
    mybusiness.accounts().locations().reviews().list(locationName);
  ListReviewsResponse response = reviewsList.execute();
  List<Reviews> reviews = response.getReviews();

  for (Reviews review : reviews) {
    System.out.println(review.toPrettyString());
  }
  return reviews;
}

कोई खास समीक्षा पाना

नाम के हिसाब से कोई खास समीक्षा वापस पाएं. किसी जगह से जुड़ी कोई खास समीक्षा वापस पाने के लिए, accounts.locations.reviews.get API का इस्तेमाल करें.

कोई खास समीक्षा वापस पाने के लिए, यह तरीका अपनाएं:

HTTP
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}
Java

यहां दिया गया फ़ंक्शन, Mybusiness.Accounts.Locations.Reviews.Get का इस्तेमाल करता है.

/**
 * Demonstrates getting a review by name.
 * @param reviewName The name (resource path) of the review to retrieve.
 * @return Account The requested review.
 */
private static Review getReview(String reviewName) throws Exception {
  Mybusiness.Accounts.Locations.Reviews.Get review =
      mybusiness.accounts().locations().reviews().get(reviewName);
  Review response = review.execute();

  return response;
}

अतिरिक्त डेटा

Java क्लाइंट लाइब्रेरी की मदद से, समीक्षा के इंस्टेंस के लिए फ़ील्ड का अतिरिक्त डेटा ऐक्सेस किया जा सकता है. समीक्षाओं के बारे में अतिरिक्त डेटा वापस पाने के लिए, इन तरीकों का इस्तेमाल करें:

  • getReviewId()
  • getComment()
  • getReviewer()
  • getStarRating()
  • getCreateTime()
  • getReviewReply()

एक से ज़्यादा जगहों की समीक्षाएं पाना

एक से ज़्यादा जगहों की समीक्षाएं पाएं. एक ही अनुरोध में एक से ज़्यादा जगहों की समीक्षाएं वापस पाने के लिए, accounts.locations.batchGetReviews API का इस्तेमाल करें.

एक से ज़्यादा जगहों की समीक्षाएं वापस पाने के लिए, यह तरीका अपनाएं:

HTTP

POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:batchGetReviews

{
  "locationNames": [
    string
  ],
  "pageSize": number,
  "pageToken": string,
  "orderBy": string,
  "ignoreRatingOnlyReviews": boolean
}

किसी समीक्षा का जवाब देना

किसी समीक्षा का जवाब दें या अगर कोई जवाब मौजूद नहीं है, तो नया जवाब बनाएं. किसी जगह से जुड़ी किसी समीक्षा का जवाब देने के लिए, accounts.locations.reviews.updateReply API का इस्तेमाल करें.

किसी समीक्षा का जवाब देने के लिए, यह तरीका अपनाएं:

HTTP
PUT
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply

{
  "comment": "Thank you for visiting our business!"
}
Java

यहां दिया गया फ़ंक्शन, Mybusiness.accounts.locations.reviews.reply का इस्तेमाल करता है.

/*
 * Updates the reply for a location review.
 * If a review does not exist, creates a new one.
 * @param reviewName Name of the review being responded to.
 * @param comment A string containing the review response body.
 * @throws IOException
 */
private static Reply reply(String reviewName, String comment) throws IOException {

  MyBusiness.Accounts.Locations.Reviews.Reply reply =
    mybusiness().accounts().locations().reviews().reply(reviewName, comment);

  Reply response  = reply.execute();

  return response;
}

समीक्षा के जवाब को मिटाना

किसी समीक्षा के जवाब को मिटाएं. किसी जगह से जुड़ी किसी समीक्षा के जवाब को मिटाने के लिए, accounts.locations.reviews.deleteReply API का इस्तेमाल करें.

किसी समीक्षा के जवाब को मिटाने के लिए, यह तरीका अपनाएं:

HTTP
DELETE
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply
Java

यहां दिया गया फ़ंक्शन, Mybusiness.Accounts.Locations.Reviews.DeleteReply का इस्तेमाल करता है.

/**
 * Demonstrates deleting a review reply by name.
 * @param reviewName The name (resource path) of the review reply to delete.
 * @return Account The requested review.
 */
private static DeleteReply deleteReply(String reviewName) throws Exception {
  Mybusiness.Accounts.Locations.Reviews.DeleteReply toDelete =
      mybusiness.accounts().locations().reviews().deleteReply(reviewName);
  DeleteReply response = toDelete.execute();

  return response;
}