- file_get_contents: documentation ( source)
- var_dump: documentation ( source)
- json_decode: documentation ( source)
- rawurlencode: documentation ( source)
<?php
$myAddress = "15502 S Memorial Dr, Bixby, OK 74445";
$myKey = "Fmjtd%7Cluu82q6y2q%2Can%3Do5-94txl0";
function GetJsonFeed()
{
global $myAddress, $myKey;
//$url = "http://www.mapquestapi.com/geocoding/v1/address?key=" . $myKey . "&callback=renderOptions&inFormat=kvp&outFormat=json&location=" . $myAddress . "&maxResults=1";
$url = @file_get_contents('http://open.mapquestapi.com/geocoding/v1/address?key=' . $myKey . '&location=' . $myAddress );
echo $url . "<br>";
$mapresponse = file_get_contents(rawurlencode($url), "r");
return json_decode($mapresponse);
}
$json = GetJsonFeed();
$jsonArr = json_decode($json);
var_dump(json_decode($json, true));
?>