Motyar

@motyar

Freelance Web Developer

Static Web Hosting, made easy

Nov 30, 2018

Google Map Scraper using Google Places API PHP

Step 1: Get an API key

You can get a key from Google Cloud Platform Console, You ll have to select a product, and set up a billing account if not already done.

Step 2: Write the code

You can use *Nearby search*, here is a quick example of the call:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&type=restaurant&keyword=cruise&key=YOUR_API_KEY

It ll return the data in JSON, you can convert that using json_decode.

 Here is a quick example code:

$jsonData = file_get_contents($apiUrl);                                
$data = json_decode($jsonData,true);  

In this data, you ll get PlaceId, You can further get full details about that place using Place details API: Here is an example:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY

Demo

 




By :