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
2010-04-06 10:11:08
cannot be the issue because OP says calling Google works
Gordon
2010-04-06 10:45:42
Oh, you're right. Sorry.
Turbotoast
2010-04-06 11:46:54
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
2010-04-06 11:09:12
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
2010-04-06 13:55:53