views:

89

answers:

3

I have a problem while using the file_get_contents function. I am using it to get a response from a different web server, but it's not returning anything (shown as empty string using var_dump). Also, the problem is only while calling this specific server, because I got result when I used Google's address; and it's working fine in my local machine. I've tried cUrl too - but same result.

A: 

Could you do:

echo ini_get('allow_url_fopen');

If this is false, you should try setting it to true in your php.ini before calling file_get_contents.

Turbotoast
cannot be the issue because OP says calling Google works
Gordon
Oh, you're right. Sorry.
Turbotoast
A: 

Maybe you need to set the user agent? Some sites may check this and disallow bots.

ini_set('user_agent', 'Name of your bot');
zaf
A: 

It might be issue with the server you are calling is the file with the appropriate permissions and is it accessible from a normal web browser? If the file access is restricted by IP is your server'sIP allowed?

Ivo Sabev