इस ट्यूटोरियल में, समीक्षा को सूची में जोड़ने, वापस करने, उसका जवाब देने, और उसे मिटाने का तरीका बताया गया है. Google My Business API से आपको समीक्षा डेटा के साथ काम करने की सुविधा मिलती है, ताकि आप ये काम कर सकें:
- सभी समीक्षाओं की सूची बनाएं.
- खास समीक्षा पाएं.
- कई जगहों की समीक्षाएं पाना.
- समीक्षा का जवाब देना.
- समीक्षा का जवाब मिटाएं.
शुरू करने से पहले
Google My Business API का इस्तेमाल करने से पहले, आपको अपना ऐप्लिकेशन रजिस्टर करना होगा और OAuth 2.0 क्रेडेंशियल हासिल करने होंगे. Google My Business API का इस्तेमाल शुरू करने के तरीके के बारे में जानकारी के लिए, बुनियादी सेटअप देखें.
सभी समीक्षाओं की सूची बनाएं
एक साथ कई समीक्षाएं ऑडिट करने के लिए, किसी जगह की सभी समीक्षाओं की सूची बनाएं. किसी जगह से जुड़ी सभी समीक्षाएं लौटाने के लिए, accounts.locations.reviews.list एपीआई का इस्तेमाल करें.
किसी जगह से जुड़ी सभी समीक्षाएं दिखाने के लिए, इनका इस्तेमाल करें:
GET https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews
यह फ़ंक्शन 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 = accountsList.execute(); List<Reviews> reviews = response.getReviews(); for (Reviews review : reviews) { System.out.println(review.toPrettyString()); } return reviews; }
खास समीक्षा पाएं
किसी समीक्षा को उसके नाम के आधार पर लिखें. किसी जगह से जुड़ी समीक्षा दिखाने के लिए, accounts.locations.reviews.get एपीआई का इस्तेमाल करें.
कोई खास समीक्षा देने के लिए, इनका इस्तेमाल करें:
GET https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}
यह फ़ंक्शन 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 एपीआई का इस्तेमाल करें.
कई जगहों से मिली समीक्षाएं दिखाने के लिए, इनका इस्तेमाल करें:
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:batchGetReviews { "locationNames": [ string ], "pageSize": number, "pageToken": string, "orderBy": string, "ignoreRatingOnlyReviews": boolean }
समीक्षा का जवाब देना
किसी समीक्षा का जवाब दें या अगर कोई जवाब मौजूद नहीं है, तो एक नया जवाब बनाएं. किसी जगह से जुड़ी किसी समीक्षा का जवाब देने के लिए, accounts.locations.reviews.updateReply एपीआई का इस्तेमाल करें.
किसी खास समीक्षा का जवाब देने के लिए, इनका इस्तेमाल करें:
PUT https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply { comment: "Thank you for visiting our business!" }
यह फ़ंक्शन 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 = reviewReply.execute(); return response; }
समीक्षा का जवाब मिटाना
किसी समीक्षा का जवाब मिटाएं. किसी जगह से जुड़ी किसी समीक्षा का जवाब मिटाने के लिए, accounts.locations.reviews.deleteReply एपीआई का इस्तेमाल करें.
समीक्षा के किसी खास जवाब को मिटाने के लिए, इनका इस्तेमाल करें:
DELETE https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply
यह फ़ंक्शन 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; }