0

I'm trying to get RSS feed from a website, But I get errors.

I tried simplexml_load_file:

$website = 'http://veida.is/feed';
$rss = simplexml_load_file($website);
print_r( $rss );

But I get the following errors:

PHP Warning:  simplexml_load_file(http://veida.is/feed): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

simplexml_load_file(): I/O warning : failed to load external entity "http://veida.is/feed"

Also with file_get_contents and simplexml_load_string:

$rss = file_get_contents($website);
$rss = simplexml_load_string($rss);
print_r($rss);

But I get:

PHP Warning:  file_get_contents(http://veida.is/feed): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

And with CURL:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $website); 
curl_setopt($ch, CURLOPT_HEADER, FALSE); 
curl_setopt($ch, CURLOPT_NOBODY, FALSE); 
curl_setopt($ch,CURLOPT_TIMEOUT,30); // TIME OUT is 5 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
$response = curl_exec($ch); 
print_r($response);
curl_close($ch); 

But I get no results back and with var_dump($response); returns bool(false).

It was working fine and if you try it may work, But after a while the same thing would happen.

They are using a service for blocking attacks like DDos, But as I use I'm just getting the feed and I mention their website.

So how to get that working again?

  • 1
    Try sending a browser useragent with Curl. ( https://stackoverflow.com/questions/17801094/php-curl-how-to-add-the-user-agent-value-or-overcome-the-servers-blocking-curl-r ) – Raymond Nijland Aug 25 '18 at 01:53
  • Possible duplicate of [Should I use proxies with simplexml\_load\_file and file\_get\_contents?](https://stackoverflow.com/questions/51977096/should-i-use-proxies-with-simplexml-load-file-and-file-get-contents) – HPierce Aug 25 '18 at 02:21
  • It's inappropriate to ask the same question multiple times. If you need more attention to your question, the proper way to do that is by [adding a bounty](https://stackoverflow.com/help/bounty) to the original. – HPierce Aug 25 '18 at 02:22
  • @RaymondNijland, I tried to use headers like the cookies, the useragent and some others, But it's not working I get blank result –  Aug 25 '18 at 04:14

0 Answers0