pondělí 4. února 2008

.Net Twitter Badge

I needed something very simple to show my twits on my homepage and written in DotNet (C#). I have downloaded the code from RSS.NET, compiled it into .NET 1.1 DLL and created a very simple code that you can embed into your .ASPX page. The library is here and it should be put in /bin folder in your website folder. The code could look somehow like this:


<%
string url = "http://twitter.com/statuses/user_timeline/8607272.rss";
Rss.RssFeed feed = Rss.RssFeed.Read(url);
Rss.RssChannel channel = (Rss.RssChannel)feed.Channels[0];
foreach (Rss.RssItem item in channel.Items)
{
Response.Write( item.Description + "&nbsp;" );
Response.Write( "<small><a href='" +item.Link + "'>" + item.PubDate + "</a></small><br><br>" );
}
%>


Make sure your page has .ASPX extension and starts with famous


<%@ Page Language="C#" Debug="false" %>

Žádné komentáře: