mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-15 21:06:33 +00:00
Add Google Geocoding example
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require '../src/Curl/Curl.php';
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
|
||||
$address = 'Paris, France';
|
||||
$curl = new Curl();
|
||||
$curl->get('http://maps.googleapis.com/maps/api/geocode/json', array(
|
||||
'address' => $address,
|
||||
));
|
||||
|
||||
if ($curl->response->status === 'OK') {
|
||||
$result = $curl->response->results['0'];
|
||||
echo
|
||||
$result->formatted_address . ' is located at ' .
|
||||
'latitude ' . $result->geometry->location->lat . ' and ' .
|
||||
'longitude ' . $result->geometry->location->lng . '.';
|
||||
}
|
||||
Reference in New Issue
Block a user