Rohit
Rohit

Reputation: 1

file_get_contents returning empty result

I'm, using file_get_contents to get the output in JSON format

$queryurl = "http://cloud.softpanda.com.au:9874/loyalty/customer/query-account?user=foo&pass=bar&format=json";
$queryurl = $queryurl . "&number=" . urlencode($cardnumber);
$queryurl = $queryurl . "&pin=" . urlencode($cardpin);

$queryresult = @file_get_contents($queryurl);
$jsonresult = @json_decode($queryresult, true);

the issue is that result is displayed when I go to the URL manually, but when I print $queryresult I get nothing. It is showing an empty result. When using this on my local server it is working fine, but when I use it on live (remote) server then I'm getting this issue.

Upvotes: 0

Views: 880

Answers (1)

hyarion
hyarion

Reputation: 2251

You need to allow

allow_url_fopen

in your php.ini config file. It is often disabled on live servers for security reasons. You can check if it is disabled by doing a phpinfo() check.

Upvotes: 1

Related Questions