Google places API using PHP

Alena picture Alena · Mar 27, 2016 · Viewed 10.4k times · Source

I'm absolutely new in using APIs. I have this code:

<head>

        <script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
        <script type="text/javascript">
            function initialize() {
                var input = document.getElementById('searchTextField');
                var options = {componentRestrictions: {country: 'ru'}};

                new google.maps.places.Autocomplete(input, options);
            }

            google.maps.event.addDomListener(window, 'load', initialize);
        </script>
    </head>
    <body>
        <label for="searchTextField">Please insert an address:</label>
        <input id="searchTextField" type="text" size="50">
    </body>

So I'm wondering if I can do the similar thing JS does here with PHP. Maybe there are some good tutorials about it (I've searched so many places but couldn't find the good one). Or maybe I'm missing something like.. There are some general rules or ways of using APIs in PHP and if I would knew them I would understand how to use Google Places API in PHP (with the help of information provided in Google's documentation). Something like that? Most of step-by-step guides and examples I found were in JS. Even in Google Documentation itself. Isn't there something for PHP? Please! Any help is precious. Thank you.

Answer

Ivan Venediktov picture Ivan Venediktov · Mar 27, 2016

You will save a lot of time by using PHP wrapper for Google Places API.