You are here:  » problems with a feed


problems with a feed

Submitted by cesare on Tue, 2006-08-01 10:44 in

Hello,
I used the magicparser demo to get the php code for the following feed:
http://feeds.feedburner.com/TheStageNews
The demo works but the following php code returns no data.

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
// This is where you write your code to process each record, such as loading a database
    // Here we just display the record contents using PHP's internal print_r() function
    
print_r($record);
  }
  
MagicParser_parse("http://feeds.feedburner.com/TheStageNews","myRecordHandler","xml|FEED/ENTRY/");
?>

Any hint?

Thank you,
Cesare

Submitted by support on Tue, 2006-08-01 11:09

Hi Cesare,

This is an interesting one!

The Magic Parser demo tool uses "wget" to fetch URLs, and then parses the local file.

The FeedBurner server seems to be returning the feed in a different format depending upon the user-agent. When using a normal browser (which WGET behaves as), the feed is returned as an ATOM feed.

However, when opened with fopen() it returns an RSS feed!

The following code works fine:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
// This is where you write your code to process each record, such as loading a database
    // Here we just display the record contents using PHP's internal print_r() function
    
print_r($record);
  }
 
MagicParser_parse("http://feeds.feedburner.com/TheStageNews","myRecordHandler","xml|RSS/CHANNEL/ITEM/");
?>

I'll look into this more and see if you can specify a parameter on the FeedBurner URL to force ATOM format.

Cheers,
David.

Submitted by cesare on Tue, 2006-08-01 11:36

Thanks David for your always fast and resolutive replies.