0

I'm trying to pull in an RSS feed into my PHP code. When I view the feed with Google Reader, I see several hundred items in the feed. However, when I pull it into my code, I'm only seeing 10.

What is the reason for the difference and how can I pull in the full feed?

ndisdabest
  • 319
  • 10
  • 19

1 Answers1

1

Since you don't show your code, it is impossible to say with certainty what is wrong. However, you tagged your question as a SimplePie question and SimplePie defaults to 10 items in some places. So, that's likely what is happening.

If you want more items, you need to tell it to show more items. See the Render Options section of the wiki documentation. Note the items option. "The number of items to show (the rest are hidden until “More” is clicked). Defaults to 10."

UPDATE: Your comment reminded me that you're using Google Reader to see what is in the RSS feed. But Google Reader will contain things that are no longer in the feed. Like Google's Feed API, Google Reader caches things for a long time (perhaps forever?) so that the user can look at entries from the deep dark past. But the actual RSS feed will not contain very old items typically, possibly to keep the RSS feed size reasonable so that response is snappy for people processing it.

Trott
  • 66,479
  • 23
  • 173
  • 212
  • My top code block: `set_feed_url('http://feeds.feedburner.com/sportsblogs/sbnation.xml'); $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); ?>` Bottom code block: `get_items() as $item) { if (preg_match($pattern, $item->get_permalink())) { echo $item->get_permalink(); } else { //do nothing } } ?>` – ndisdabest Oct 12 '12 at 12:33
  • I'm not sure what line to add to my script in order to make this work -- unfortunately, I'm not a seasoned PHP developer and don't really know where to place the line that will make this work. If you could offer a pointer, I'd really appreciate it! – ndisdabest Oct 12 '12 at 12:49
  • Now that you've posted your code, it doesn't look to me like what I surmised is what is happening. Your code appears to be reading in the entire RSS feed, but then only showing entries where the permalink starts with `http://www.sbnation.com/college-football/`. Perhaps there are only ten items like that. I'm looking at the feed now and I see zero items like that, so I'm not sure what's up. – Trott Oct 12 '12 at 12:53
  • It's strange... if you plug the feed into Google Reader, there are hundreds of items, but not when you pull it in through SimplePie. As you suggested, I'm basically trying to create a filtered feed since this particular site doesn't spike out RSS for its college football section, hence the reason I'm doing a regular expression match. – ndisdabest Oct 12 '12 at 13:05
  • Ah! That's because Google Reader caches old results. I'll update my answer. – Trott Oct 12 '12 at 13:06