jarv Posted February 21, 2015 Share Posted February 21, 2015 Hi, My codes does not show any Latitude or Longitude but it did last night when I started writing this code?! $postcode = 'BN113ED'; $response = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($postcode) . '&sensor=true'); $response = json_decode($response); $lat = $response->results[0]->geometry->location->lat; $long = $response->results[0]->geometry->location->lng; here is the URL that shows the JSON http://maps.googleapis.com/maps/api/geocode/json?address=bn113ed&sensor=true Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted February 21, 2015 Share Posted February 21, 2015 I see no issue with that code. It returns the the lat and long for me after I add echo "$lat, $long"; What does the following return? printf('<pre>%S</pre>', print_r($response, 1)); Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted February 21, 2015 Share Posted February 21, 2015 (edited) The code works fine for me as well adding echo Is there api usage limits? Edited February 21, 2015 by QuickOldCar Quote Link to comment Share on other sites More sharing options...
jarv Posted February 21, 2015 Author Share Posted February 21, 2015 no nothing, and your line of code didn't output anything?! Quote Link to comment Share on other sites More sharing options...
jarv Posted February 21, 2015 Author Share Posted February 21, 2015 I just got this message so hopefully I can geocode more postcodes tomorrow?! var_dump() results jason response string(137) "{ "error_message" : "You have exceeded your daily request quota for this API.", "results" : [], "status" : "OVER_QUERY_LIMIT" } " jason decoded object(stdClass)#1 (3) { ["error_message"]=> string(56) "You have exceeded your daily request quota for this API." ["results"]=> array(0) { } ["status"]=> string(16) "OVER_QUERY_LIMIT" } lat NULL long NULL // $qr = "SELECT * FROM pubs WHERE rsTown = 'Worthing'"; // // $res= mysql_query($qr); // $i=0; // while($row = mysql_fetch_array($res)) // { // $postcode = $row["rsPostCode"]; // $response = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($postcode) . '&sensor=true'); // $response = json_decode($response); // // $lat = $response->results[0]->geometry->location->lat; // $long = $response->results[0]->geometry->location->lng; // // $qr = "UPDATE pubs SET rsLat='$lat',rsLong='$long' WHERE rsPostCode = '$postcode'"; // // //echo $qr; // $res= mysql_query($qr); // echo $qr; // // $i++; // } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.