1

I am using simplexml_load_file() in a function an it works with every rss successful But i have a problem with Rss of this site for example:

http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2

I cannot get this page source using file_get_contents() too;

There are my Errors:

Warning: simplexml_load_file(http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:\wamp\www\php\44\xml.php on line 5

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2" in C:\wamp\www\php\44\xml.php on line 5
bool(false)

How can i use this RSS? please help me.

2
  • HTTP/1.1 403 Forbidden You dont have permission to access that resource. Commented Nov 12, 2014 at 21:28
  • First warning kind of says it: server issued a 403 Forbidden response. Commented Nov 12, 2014 at 21:28

1 Answer 1

10

As I said in my comment:

HTTP/1.1 403 Forbidden You dont have permission to access that resource.

However I can hit it from a browser so it may be something to do with a user agent (or some other HTTP header its trying to validate). In that case you can use curl to pull the data and supply whatever user agent (or other necessary header) you like.

$ch = curl_init('http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Identify the rquest User Agent as Chrome - any real browser, or perhaps any value may work
// depending on the resource you are trying to hit
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36');


$feed = curl_exec($ch);
$rss = new SimpleXMLElement($feed);
Sign up to request clarification or add additional context in comments.

1 Comment

You are very very kind. I love you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.