Google places API using PHP

12,452

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

Share:
12,452
Alena
Author by

Alena

Updated on June 04, 2022

Comments

  • Alena
    Alena almost 2 years

    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.