Bu eğitimde, yorumları nasıl listeleyebilir, iade edebilir, yanıtlayabilir ve silebilirsiniz? Google Benim İşletmem API'si, aşağıdaki işlemleri gerçekleştirmek için yorum verileriyle çalışmanıza olanak tanır:
- Tüm yorumları listeleyin.
- Belirli bir yorumu alın.
- Birden fazla konumdan yorum alın.
- Yorumları yanıtlama
- Yorum yanıtını silme.
Başlamadan önce
Google Benim İşletmem API'sini kullanmadan önce uygulamanızı kaydettirmeniz ve OAuth 2.0 kimlik bilgilerini almanız gerekir. Google Benim İşletmem API'sini kullanmaya başlama hakkında ayrıntılı bilgi için Temel kurulum bölümüne bakın.
Tüm yorumları listeleme
Yorumları toplu olarak denetlemek için bir konumla ilgili tüm yorumları listeleyin. Bir konumla ilişkili tüm yorumları döndürmek için accounts.locations.reviews.list API'sini kullanın.
Bir konumla ilişkili tüm yorumları döndürmek için aşağıdakileri kullanın:
GET https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews
Aşağıdaki işlevde Mybusiness.Accounts.Locations.Reviews.List
kullanılır.
/** * 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; }
Belirli bir yorumu alma
Belirli bir yorumu isme göre döndürme Bir konumla ilişkili belirli bir yorumu döndürmek için accounts.locations.reviews.get API'sini kullanın.
Belirli bir yorumu iade etmek için aşağıdakileri kullanın:
GET https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}
Aşağıdaki işlevde Mybusiness.Accounts.Locations.Reviews.Get
kullanılır.
/** * 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; }
Ek veriler
Java istemci kitaplığı, inceleme örnekleri için ek alan verilerine erişmenizi sağlar. Yorumlarla ilgili ek veriler döndürmek için aşağıdaki yöntemleri kullanın:
getReviewId()
getComment()
getReviewer()
getStarRating()
getCreateTime()
getReviewReply()
Birden fazla konumdan yorum alma
Birden fazla konumdan yorum alın. Birden fazla konumdaki yorumları tek bir istekle döndürmek için accounts.locations.batchGetReviews API'sini kullanın.
Birden fazla yerden gelen yorumları döndürmek için aşağıdakileri kullanın:
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:batchGetReviews { "locationNames": [ string ], "pageSize": number, "pageToken": string, "orderBy": string, "ignoreRatingOnlyReviews": boolean }
Yorumları yanıtlama
Belirli bir yorumu yanıtlayın veya yoksa yeni bir yanıt oluşturun. Bir konumla ilişkili belirli bir yorumu yanıtlamak için accounts.locations.reviews.updateReply API'sini kullanın.
Belirli bir yorumu yanıtlamak için aşağıdakileri kullanın:
PUT https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply { comment: "Thank you for visiting our business!" }
Aşağıdaki işlevde Mybusiness.accounts.locations.reviews.reply
kullanılır.
/* * 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; }
Yorum yanıtını silme
Belirli bir yoruma verilen yanıtı silme. Bir konumla ilişkili belirli bir yoruma verilen yanıtı silmek için accounts.locations.reviews.deleteReply API'sini kullanın.
Bir yoruma verilen belirli bir yanıtı silmek için aşağıdakileri kullanın:
DELETE https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply
Aşağıdaki işlevde Mybusiness.Accounts.Locations.Reviews.DeleteReply
kullanılır.
/** * 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; }