Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Resolve city from long/lat data using GeoNames API. Example uses the demo account, a live site would need an API key. */
- public function resolveCity($lat, $lng)
- {
- $url = "http://api.geonames.org/findNearbyPlaceNameJSON?lat=" . $lat . "&lng=" . $lng . "&username=demo";
- // make the HTTP request
- $data = @file_get_contents($url);
- $jsondata = json_decode($data,true);
- // Grab the location
- $location = $jsondata['geonames'][0]['name'];
- // Return the location
- return $location;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement