-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbing_test.php
More file actions
19 lines (18 loc) · 841 Bytes
/
bing_test.php
File metadata and controls
19 lines (18 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
session_start();
$address = isset($_GET['address']) && $_GET['address'] != '' ? htmlentities($_GET['address']) : '902 Broadway';
$city = isset($_GET['city']) && $_GET['city'] != '' ? htmlentities($_GET['city']) : 'New York';
$_SESSION['address'] = $address;
$vars = rawurlencode($address.' '.$city.' NY');
$ch = curl_init("http://dev.virtualearth.net/REST/v1/Locations/{$vars}?o=json&key=Astz1QZHF2CCNpI6aMVIXtchjBuAUIXTt2PBlI7UrMPbsNoousBCc_bXtYR_40cb");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
preg_replace('/%u([a-fA-F0-9]{4})/', '&#x\\1;', $output);
curl_close($ch);
$data = json_decode($output);
$resource = $data->resourceSets[0]->resources[0];
$postalcode = $resource->address->postalCode;
$lat = $resource->point->coordinates[0];
$long = $resource->point->coordinates[1];
echo $lat.':'.$long;
?>