View Single Post
  #1 (permalink)  
Old 05-30-2008, 12:18 PM
CygnetGames's Avatar   
CygnetGames CygnetGames is offline
Programmer
 
Join Date: May 2007
Location: York, England
Posts: 113
Rep Power: 6
CygnetGames is on a distinguished road
Default RSS feeds and cURL

Hi all,

I'm using cURL from within a PHP webpage to display some RSS feeds on my site. I'm displaying comics from the xkcd feed and the Dilbert feed. The xkcd feed works perfectly, but Dilbert does something very strange.

At certain times of day Dilbert works fine, but at other times it does a 302 redirect to a different page with an older comic on it. However, only cURL seems to get this 302 redirect. When you paste the url into Firefox, you get the current comic!

This is really confusing me as I'm not sure whether the problem is in my code or in the Dilbert RSS feed. It's happened consistently for the last three days though. It works fine from around 11:00pm (GMT) to around 11:00am (GMT), and does the redirect from 11am until 11pm. (The times are only very rough, I haven't tracked them down precisely.)

The url I am using for the Dilbert feed is:
Code:
http://feeds.feedburner.com/DilbertDailyStrip?format=xml
and the one it redirects to is:
Code:
http://feedproxy.feedburner.com/DilbertDailyStrip?format=xml
My cURL code is:
PHP Code:
$ch curl_init();

curl_setopt($chCURLOPT_URL$feedURL);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_FOLLOWLOCATION1);

curl_setopt($chCURLOPT_VERBOSE1);
$out fopen('out '.urlencode($feedURL).time().'.txt''w');
curl_setopt($chCURLOPT_STDERR$out);

$buffer curl_exec($ch);

curl_close($ch);
fclose($out); 
Hopefully, someone may be able to shed some light on this - it's really puzzling me!
Reply With Quote

Sponsored Links