Home » API » Web » Integrate Google Places API for Text Search

Integrate Google Places API for Text Search

Posted in API, Web Tagged , , ,

Problem

Build a prototype using Google Places API which will search for all the restaurants, based on any text query entered for a given location. The search results should return the place photos, place details, reviews and ratings.

Solution Provided

google-places

The Google places API needs an API key to operate. Once that is generated by signing up, they are a number of web service calls which have to be made to fetch the relevant data. The text-search service was used to obtain the data for the specified text query. The request was made using CURL in PHP. Not all the place details that are needed are returned by the text-search service alone. It gives a key called as a reference id which needs to be passed on to a place details service which then returns the detailed info of the place. The photos of the place were obtained using the place photo web service call.  The photo reference key obtained from the detail request needs to be passed as part of the photo service call. You can also pass the maxwidth / maxheight parameter and the thumbnail will be returned with the mentioned dimension and correct aspect ratio.

Radius search was also implemented to fetch the data based on a specified miles range.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>