Question

I am trying to simply use file_get_contents() to get content of http://www.google.com/search?hl=en&tbm=nws&authuser=0&q=Pakistan with same code on 2 different servers. One is getting every thing file while other is getting 403 error. I am unable to know what exactly the reason is. I used phpinfo() on both servers.

One difference I observe is that one use apache2 while other use some other HTTP server named LiteSpeed V6.6. But i don't know how if it affect this file_get_contents() method. For more detail you can see their phpinfo() page link below. Where file_get_contents getting 403 the phpinfo is; http://zavahost.com/newsreader/phpinfo.php

while where it is working file , here is the phpinfo: http://162.243.5.14/info.php

I will be thankful if someone can tell that what is effecting file_get_contents()? Please let me know if any idea?

Was it helpful?

Solution

403 is an Unauthorized Error. That means you lack sufficient permission to connect to the content at that server. I'm not sure if this could be due to the inability to fetch data from your hosting provider, but it could also be denied based on header information the remote server has flagged as unauthorized.

Try using the answer on this post: php curl: how can i emulate a get request exactly like a web browser? to curl the same data from the server that is getting the 403

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top