Question

Three hours ago I was working on my site, then I had a nap, and now my file_get_contents request isn't working.

$Url = sprintf( "http://www.wowhead.com/item=%u?xml", $EntryId );
$Xml = file_get_contents( $Url );    

Display ID for example could be 30987. The url formed: http://www.wowhead.com/item=30987?xml This works in a browser - but in my site I get: failed to open stream: HTTP request failed!.

I don't really get it - because it worked perfectly just 3 hours ago.

Does anyone have any idea? Thanks.

Was it helpful?

Solution

They way you are reading the HTTP content can be the problem. You are reading it as a file. That does not send proper HTTP headers. Server may refuse to serve the page contents when the request is not formatted properly. Read the contents of the URL using HTTPRequest

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