GET request working in test but not on server; PHP functions denied?

Avatar
  • Answered
Hi, I have a script that is meant to fetch some data from a third party. It works just fine on my home machine but when I put it on your server, it doesn't work. I'm using the following PHP code; please can you tell me if something has been denied? If so, can you suggest an alternative method? I need to send a GET request with an extra header, in this case named 'Authorization'.

$url and $apikey are defined earlier in the code.
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: ".$apikey."\r\n"
)
);
$context = stream_context_create($opts);
$file = file_get_contents($url, false, $context);

I never receive the $file variable.

Thank you,
Jo
Avatar
Arn
Hello Jo, Sorry for the problems with the code you're trying to put together to retrieve data from a third party. When you attempt to do this in an environment between different networks, the typical problem is specifying the data sources and providing the credentials for access to and from each source. For example, we have articles on how to fetch data from MySQL databases. The tutorials we provide are the extent to which provide support for coding. Providing support development beyond is out of scope for our support. Apologies that we cannot provide a solution directly. Check out other forums such as this one that may provide much more information on the topic. I hope that helps to provide more information for your question! If you require further assistance, please let us know! Regards, Arnel C.