How to Fetch Google Places (NEW) Reviews

To fetch Google Places (NEW) reviews on a website, you can use JavaScript along with the Google Maps JavaScript API. Here’s an example code snippet:

<!DOCTYPE html>
<html>
<head>
    <title>Google Places Reviews</title>
    <!-- Include the Google Maps JavaScript API -->
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places"></script>
</head>
<body>

<div id="google-reviews">
    <!-- Google reviews will be displayed here -->
</div>

<script>
    // Replace 'YOUR_API_KEY' with your actual Google API key
    const apiKey = 'YOUR_API_KEY';
    const placeId = 'YOUR_GOOGLE_PLACE_ID'; // Replace with your Google Place ID

    // Create a new PlacesService object
    const service = new google.maps.places.PlacesService(document.createElement('div'));

    // Request place details including reviews
    service.getDetails({
        placeId: placeId,
        fields: ['reviews'],
        key: apiKey
    }, function(place, status) {
        if (status === google.maps.places.PlacesServiceStatus.OK) {
            const reviews = place.reviews;

            const reviewContainer = document.getElementById('google-reviews');

            reviews.forEach(review => {
                const rating = review.rating;
                const authorName = review.author_name;
                const text = review.text;

                const reviewDiv = document.createElement('div');
                reviewDiv.innerHTML = `<p><strong>${authorName}</strong> (${rating} stars)</p><p>${text}</p>`;
                reviewContainer.appendChild(reviewDiv);
            });
        } else {
            document.getElementById('google-reviews').innerHTML = 'No reviews found.';
        }
    });
</script>

</body>
</html>

Remember to replace 'YOUR_API_KEY' with your actual Google API key and 'YOUR_GOOGLE_PLACE_ID' with the Place ID of your business on Google Maps.

This code uses the google.maps.places.PlacesService to fetch place details, including reviews, for the specified Place ID. It then dynamically creates HTML elements to display the retrieved reviews on the webpage.

Make sure to comply with Google’s terms of service and API usage policies while implementing this on your website. Also, keep in mind that this example assumes that the Google Maps JavaScript API is properly loaded and available in your web page.