Hi Team ,
Can you help me to How to Post Review in Google review by using Any .dot net Project
Hi Team ,
Can you help me to How to Post Review in Google review by using Any .dot net Project
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajkiran SwainRank #165 · 14.4K reputationPosted May 9, 2023, 8:42 AM EDT
using System; using System.IO; using System.Net; using System.Text; class GoogleReviewPoster { private const string URL = "https://www.google.com/maps/api/place/add/json"; public void PostReview(string placeId, string reviewText, int rating) { // Set up the request body as a JSON string string requestBody = $"{{\"location\": {{\"placeId\": \"{placeId}\"}}, \"text\": \"{reviewText}\", \"rating\": {rating}}}"; // Create the HTTP request HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = requestBody.Length; // Write the request body to the request stream using (Stream requestStream = request.GetRequestStream()) { byte[] requestBodyBytes = Encoding.UTF8.GetBytes(requestBody); requestStream.Write(requestBodyBytes, 0, requestBodyBytes.Length); } // Get the HTTP response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Check if the response was successful (HTTP status code 200-299) if ((int)response.StatusCode >= 200 && (int)response.StatusCode <= 299) { Console.WriteLine("Review posted successfully!"); } else { Console.WriteLine("Error posting review: " + response.StatusCode); } } }To use this code, you can create a new instance of the
GoogleReviewPosterclass and call thePostReviewmethod, passing in the Google Place ID of the location you want to review, the text of your review, and a rating between 1 and 5. For example:GoogleReviewPoster reviewPoster = new GoogleReviewPoster(); string placeId = "ChIJrTLr-GyuEmsRBfy61i59si0"; // Example place ID for the Eiffel Tower in Paris string reviewText = "I had a great time visiting the Eiffel Tower!"; int rating = 5; reviewPoster.PostReview(placeId, reviewText, rating);Note that in order to use this code, you will need to obtain an API key for the Google Maps Places API and include it in your requests. You can find more information on how to obtain an API key and use the Places API in the official Google documentation.