2

I am trying to get RSS from other sites. They all work fine using file_get_contents except one link give me this error:

Warning: file_get_contents(http://alwatan.kuwait.tt/rss.ashx): failed to open stream: HTTP request failed! HTTP/1.1 463

I download all files and all have:

<rss version="2.0">

but the link with error have:

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

this is the only difference between them.

chris85
  • 23,846
  • 7
  • 34
  • 51
Haithomy
  • 73
  • 2
  • 8
  • The page is probably checking for bots. Try using curl + header and user agent headers. http://stackoverflow.com/a/2570832/1935500 – Aziz Saleh Feb 20 '16 at 15:54

1 Answers1

5

Looks to me that that feed is not allowing you to grab it.

463 Restricted Client: This resource is not available for access by your client software. This request has been blocked. Please retry your request from a different client.

DOSarrest Internet Security is a cloud based fully managed DDoS protection service. This request has been blocked by DOSarrest due to the above violation. If you believe you are getting blocked in error please contact the administrator of scripts.local to resolve this issue.

You can test this by trying to use a curl instead of file_get_contents

<?php

$ch = curl_init("http://alwatan.kuwait.tt/rss.ashx");

curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
curl_setopt($ch, CURLOPT_USERAGENT, "spider");

curl_exec($ch);
curl_close($ch);

?>

As Aziz mentioned, if you set the agent and the referred, you can get through.

Mark
  • 373
  • 2
  • 11
  • 1
    I would also mimic the user agent and referral which are the 2 mostly common checked headers. – Aziz Saleh Feb 20 '16 at 15:55
  • Let me give it a try and see if they allow it – Mark Feb 20 '16 at 15:57
  • thanks man I try cURL and still not working but when I play around with cURL options I found `CURLOPT_USERAGENT, "spider"` and it solve my problem and everything is fine now – Haithomy Feb 20 '16 at 16:35
  • Cool glad you got it working, please accept the answer if you're happy with it. – Mark Feb 20 '16 at 16:48