PHP Developers Network
http://forums.devnetwork.net/

api works in dev and test but not on Network Solutions...
http://forums.devnetwork.net/viewtopic.php?f=1&t=147850
Page 1 of 1

Author:  orbdrums [ Mon Jun 18, 2018 8:54 pm ]
Post subject:  api works in dev and test but not on Network Solutions...

I have some code that works just fine on my DEV and TEST environments but returns nothing in PROD (Network Solutions hosted). I am including the code and am looking for any suggestions. I have used just the API call and it works fine from multiple machines AND as an HTML file in PROD, but when the following will not return data in PROD.
Syntax: [ Download ] [ Hide ]
<?
session_start();
$jsonurl = "http://api.openweathermap.org/data/2.5/weather?q=Boston&appid=somethinggoeshere";
$json = file_get_contents($jsonurl);
$weather = json_decode($json);
$kelvin = $weather->main->temp;
$celcius = $kelvin - 273.15;
$fahrenheit = round($celcius * 1.8 + 32);
$pressure = $weather->main->pressure;
$desc = $weather->weather->description;
echo 'Irvine: '.$fahrenheit.' Description: '.$pressure;
echo '<br/>OpenWeatherMap Data: '.$json;
?>
 

Many thanks in advance.

Author:  benanamen [ Mon Jun 18, 2018 9:40 pm ]
Post subject:  Re: api works in dev and test but not on Network Solutions..

"somethinggoeshere" should be a valid API key. Are you using one?

Author:  orbdrums [ Mon Jun 18, 2018 9:45 pm ]
Post subject:  Re: api works in dev and test but not on Network Solutions..

I am but I didn't want to provide a fully functional api for obvious reasons.

Author:  orbdrums [ Tue Jun 19, 2018 2:13 pm ]
Post subject:  Re: api works in dev and test but not on Network Solutions..

[SOLVED]
Using the curl_exec() function instead of get_file_contents() resolved the issue. Thanks all.

Author:  Christopher [ Wed Jun 20, 2018 12:34 pm ]
Post subject:  Re: api works in dev and test but not on Network Solutions..

The problem may be allowed stream wrappers. See:

http://php.net/manual/en/wrappers.php

And also the manual on fopen wrappers:

http://php.net/manual/en/filesystem.con ... -url-fopen

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/