Granze
Granze

Reputation: 517

Error 500 retrieving a rss feed

I'm trying to retrieve a rss feed from this URL: http://www.8a.nu/rss/Main.aspx?UserId=19212&AscentType=0&ObjectClass=2&GID=3974d72911c05719152f0953e88cc2df

There is no problem if you point at that address with your browser, but I get a 500 error if I try to get the feed with file_get_contents. I've tried cURL as well with the same result.

I also tried to copy the result via wget and lynx without success.

Here you can see/test the script: http://codepad.viper-7.com/Qjrjay

Upvotes: 0

Views: 389

Answers (2)

Granze
Granze

Reputation: 517

The real problem was the user agent sniffing.

For a quick workaround I've added on top of my script:

 ini_set("user_agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); 
 ini_set("max_execution_time", 0);
 ini_set("memory_limit", "10000M");

It works now!

Upvotes: 1

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

This worked for me:


$baseurl = "http://www.8a.nu/rss/Main.aspx?";
$query = urlencode("UserId=19212&AscentType=0&ObjectClass=2&GID=3974d72911c05719152f0953e88cc2df");
$final_uri = $baseurl.$query;
$response = file_get_contents($final_uri);
header ("Content-Type:text/xml");
echo $response;

Hope it helps

Upvotes: 2

Related Questions