Friday, 27 January 2017

How To Use Curl In Php For Json Results From Google Places Api

<?php
$url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?
location=28.636736,77.27480700000001&radius=5000&types=school&sensor=false&key=YOUR_API_KEY";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
echo $name = $response_a->results[0]->name;
?>

No comments:

Post a Comment