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?