Written March 30, 2008 in zend framework

Let’s say you’re scanning a website for it’s feeds using Zend_Feed::findFeeds($URL). The function looks at a website, and checks for the link tags in the head part of the document that would indicate that it has feeds. Then it returns an array of those feeds.

Now, for the sake of argument, let’s say you don’t want to have to make the HTTP request using findFeeds() again. Say you wanted to store the address of the feed you’ve selected. How would that work? There isn’t a getURI method to Zend_Feed_RSS or Zend_Feed_Atom. Take a look a little deeper into the framework. Zend_Feed implements a singleton pattern, and stores any other singleton objects inside the instance of Zend_Feed. So you can call Zend_Feed::getHttpClient()->getUri(true); — and you’ll have the URI of the most recent request that came out of the Zend_Feed::import() function. Voila, there’s the actual address of the RSS feed that you just sucked in from findFeeds().

Ladies and gentlemen, Matthew Weier-O’Phinney is a programming genius. He and the rest of the Zend Framework team have built the most extensible, accessible framework anywhere. It just takes a little bit of time to wrap your brain around it. Stick with it, it’s worth it!


Related:

1 comment on ' Zend Framework: Get RSS Feed’s URI '

  1. This doesn’t work if there are multiple tags on the same page - it only provides the last URI in the list. It would be much cleaner if there were a getUri() function in Zend_Feed_Abstract so that each feed carries its source URI with it.

      Written by MJH on July 28, 2008 at 2:51am

Leave a comment

name (req'd)

email (req'd)

website