GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
works on Localhost, but not on server  XML
Forum Index -> General
Author Message
dcapitalj



Joined: 09/02/2018 13:39:00
Messages: 1
Offline

I'm a newbie, sorry if my question is easy...

I'm trying to get the JSON output of Geonames Timezone into a PHP array.
Below is the code (username changed because I don't think that should be public?)
The code works on my Localhost, but when I upload it to my server, it doesn't. What could be wrong?
Thanks in advance...

$lat=10;
$long=6;
$url = "http://api.geonames.org/timezoneJSON?lat=$lat&lng=$long&username=MY_USERNAME";
# I ALSO TRIED $url = "http://api.geonames.org/timezoneJSON?lat=".$lat."&lng=".$long."&username=MY_USERNAME";

rawurlencode(utf8_encode($url));

$data = file_get_contents($url); // put the contents of the file into a variable

$decoded = json_decode($data, true); // decode data

print_r($decoded); // prints the resulting array
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team