A .NET class to consume wordpress RSS
Thursday, November 20th, 2008Wordpress as a CMS is not a new phenomena, and I have used wordpress as the engine for many websites and blogs, both as a complete out the box system and as a backend admin system.
So this morning I decided to make a .NET class file purely to consume wordpress RSS feeds, allowing you to use Wordpress as the back end CMS and a .NET application as the front end populated from the wrodpress rss data.
This is actually really easy to do using the RSS Toolkit available from Codeplex. I have done this before, maybe a year ago, when building an app to consume the Seesmic RSS feed. It worked like a dream, because you can add whatever namespaces you like to help create the class, including the yahoo media namespace which defines the RSS structure for video and images etc.
The process works like this:
Head over to Codeplex and download the RSS Toolkit binaries. Unzip the binaries and you will find a tool called RssDl.exe located inside the folder: RssDl\bin\Release
The RssDI.exe tool is the command line RSS compiler that creates RSS class files. Simply open the command prompt and change directory to the location of the RSSDI.exe tool.
Then run the following command, altering the syntax according to the name of the class file you wish to make and the location of the RSS feed you wish to use as a basis for the class file:
rssdl.exe http://domain.com/path/to/your/rss.xml wordpress.vb
Let’s break the above down. It’s pretty straight forward. You run the tool rssdl.exe, giving it the url of the rss file you wish to consume to create the class file. Finally, the name of the classfile you want to create, in this case, wordpress.vb. You can create either c# or vb files using this method.
One thing to note, if you are using VB, I have always found this tool to be create the file with a couple of errors. So copy and paste the created file into the AppCode folder and check for any syntax errors. You might need to change “is” to “=” on a line that is showing an error. I have no idea why, but that’s my experience of this tool. Leave a comment here if you are having issues with it.
Once you have created this file and pasted into the AppCode folder in Visual Studio, you are ready to consume your feeds. Drop a repeater, datagrid or datalist onto the page, e.g.
<p>
<asp:Repeater ID=”rptButtons” runat=”server”>
<ItemTemplate>
<asp:Label ID=”Label1″ runat=”server” Text=”" ><%# Eval(”Title”)Â %></asp:Label><br />
<asp:Label ID=”Label2″ runat=”server” Text=”"><%# Eval(”Description”)Â %></asp:Label><br />
<asp:Label ID=”Label6″ runat=”server” Text=”"><%# Eval(”pubDate”)%></asp:Label><br />
</ItemTemplate>
</asp:Repeater>
</p>
Add the following code to bind the RSS data to the control, replacing the url for your chosen wordpress RSS feed:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rss As RssToolkit.Rss.RssDocument = RssToolkit.Rss.RssDocument.Load(New System.Uri(”http://www.yellowpark.net/cdalby/index.php?feed=rss2&cat=7″))
rptButtons.DataSource = rss.SelectItems()
rptButtons.DataBind()
End Sub
It really is as simple as that. So if you want to have a different feed populating a different page throughout your .NET website, you could create a new category called About Us, and use that feed to populate the About Us page in your .NET website.
More details on Wordpress RSS feeds here.
One more final point about this method of consuming RSS. You could simply consume the RSS feed using the built in .NET tools. I prefer this method because you get a custom class file that is designed specifically to deal with whatever the rss feed looks like that then behaves as expected and gives you full control over the look of the data in your website.
The Seesmic .NET Time Drain
Wednesday, January 30th, 2008I have created the Seesmic .NET Time Drain using ASP.NET Ajax. I’m not making it public at the moment, because in true seesmic style, it is pre-alpha. But if you find it, then great.
This project has been developed with the intention of creating a .NET class and library allowing other .NET developers to easily build on the Seesmic API and platform.
I have not been paid to create Time Drain. So there are bugs. I offer no warranty or guarantee regarding the suitability of the code or usability of Time Drain. There are no warranties, and no special offers or cuddly toys.
What I hope this does do, is go some way to opening up seesmic to the .NET developer community allowing us all to benefit from new and usefull apps. Ping me if you want to get involved.
New seesmic features released
Wednesday, January 30th, 2008Dennis Howlett wrote a great post this evening (or morning) about the new features released by Seesmic. A huge improvement. All those features you wanted. They are here!
A big thanks to Dennis for the mention about my Seesmic .NET Time Drain. Rather than re-writing Dennis’s post, get it over here.
Johann has also written a blog post about the new features. Nice work to all the dev team at seesmic. It’s been amazing to see how you have listened to the community and implemented the features we all wanted. Great job!