to LooselyCoupled.com homepage
 Weekly emails: how to  

 

> how to > functions > Pro2rss


RSS feed from a Blogger Pro blog


Pro2rss is a PHP program that reads a Blogger Pro weblog page and converts the contents into an RSS feed containing a title, permalink and description for each separate entry (up to a maximum of 15 entries). It works by reading some extra tag information that you'll need to add to your blog's template.

Thanks to Julian Bond, whose code for RSSify at VoidStar.com was the starting point for Pro2rss. Thanks also to Aaron Swartz, whose Syndicate Your Page was the inspiration for Julian's work, and finally to Zend, whose PHP Function Table was invaluable for figuring out what the code actually did.

Recommended use is as follows:

  1. The program assumes you are using <div> ... </div> tags to mark the beginning and end of each Blogger entry (ie all the item-specific Blogger tags — those are the ones with "Item" in them, such as <$BlogItemNumber$>, <$BlogItemSubject$>, <$BlogItemBody$> and <$BlogItemDateTime$> — fall within the <div> ... </div> tags). If this isn't the case, you'll need to add or move them.
  2. Add id="rssi0" to the opening <div> tag, like this: <div id="rssi0">
  3. The current version of the program assumes you are using <h5> ... </h5> tags around the subject title for each entry (I'm hoping this can be changed in a later version so that you can choose any level of heading). Add id="rssi1" to the opening tag, like this:
    <h5 id="rssi1"><$BlogItemSubject$></h5>
  4. The final step is to mark your permalink with id="rssi2", like this:
    <a id="rssi2" href="http://www.domain.com/path/ <$BlogItemArchiveFileName$>#<$BlogItemNumber$>">
    where "www.domain.com/path" is the domain and path for your archive. (It's important to keep the id statement directly in front of the href statement, so if you want to add anything like a class or target statement, put them before the id or after the href).
  5. When you've saved the changes to your template, publish your blog and it will then be ready for Pro2rss.
  6. You can check that it works OK by putting the URL of your blog into the form below. You should see the relevant material from your page appearing in your browser as a raw RSS feed, complete with XML tags.
  7. Now you have some choices.
    1. You can save the XML into a file (called eg "YourBlogName.xml") and then upload it to your web server. This does mean that you'll have to repeat the process each time you update your blog, but it gives you control over the permanent URL for the feed, even if you change how you write the file in the future. (I am looking at adding ftp capabilities to a later version of this page, which of course will then make it a much simpler process).
    2. If you have access to a server that runs PHP (you probably do — most shared Unix hosting services include PHP as standard) you can download a copy of the code and install it on your own server, making amendments as appropriate. If you're not familiar with PHP, download this annotated version of the code as well. It has comments added that tell you what each part of the program does.
    3. One other option is to make a link directly to this page, adding "?url=" and then your weblog url, like this: "http://howto.looselycoupled.com/fn/pro2rss.php?url=your_weblog_url". This option is 'deprecated', as they say, since although the page works OK for now, I can't guarantee that it always will in the future.
  8. Be sure to check that your RSS feed is valid. You can do this at the Userland validator or the Schematron Validator.
  9. Finally, put one of these little orange This XML gif is freely copyable - right-click to save icons on your weblog, and link it to the RSS feed that you've created using Pro2rss. For an example, view the source for the Loosely Coupled weblog.
  10. You're welcome to copy and amend the code, but please acknowledge Pro2rss with a link to this page.

The URL of your web page:
(include http:// and a final "/" or a filename)

To find out more about RSS, see Julian Bond's RSS FAQ. If you have any problems or questions about the code, email me at pw@philwainewright.com. The latest revision, to version 0.95a, was made Jan 2nd, 2006, and uses Curl functions to read your blog instead of fgets(), which nowadays is not recommended for reading remote files. The previous revision was from version 0.90 to version 0.95, May 29th, 2002. For FAQs, see the AppSwitching Diary.

 
 


Copyright © 2002-2010, Procullux Media Ltd. All Rights Reserved.