سؤال

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.

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top