<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Adventures In Development &#187; Social Media</title>
	<atom:link href="http://www.adventuresindevelopment.com/category/social-media/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adventuresindevelopment.com</link>
	<description>Web Development Tools, Ideas, Techniques and Resources</description>
	<lastBuildDate>Wed, 25 Jan 2012 20:41:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Display Your Twitter Feed using ASP.NET</title>
		<link>http://www.adventuresindevelopment.com/2009/06/21/how-to-display-your-twitter-feed-using-aspnet/</link>
		<comments>http://www.adventuresindevelopment.com/2009/06/21/how-to-display-your-twitter-feed-using-aspnet/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 00:08:38 +0000</pubDate>
		<dc:creator>Matthew Paulson</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Content Management Systems]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.adventuresindevelopment.com/?p=145</guid>
		<description><![CDATA[UPDATE 3/23/2010 - Ricky from Twitterizer commented below noting that basic authentication will soon go away via Twitter and OAUTH will be required. Note that the code below will only work for a few months. We will post an updated code-example soon. As I write this article, It&#8217;s about 75 degrees and Sunny outside. When &#8230; <a href="http://www.adventuresindevelopment.com/2009/06/21/how-to-display-your-twitter-feed-using-aspnet/">Continue reading</a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE 3/23/2010 </strong>- Ricky from Twitterizer commented below noting that basic authentication will soon go away via Twitter and OAUTH will be required. Note that the code below will only work for a few months. We will post an updated code-example soon.</p>
<p>As I write this article, It&#8217;s about 75 degrees and Sunny outside. When I should be going out on a bike ride, instead I&#8217;ve opted to play with <a href="http://code.google.com/p/twitterizer/">Twitterizer</a> (an ASP.NET Twitter Library). Twitterizer is an ASP.NET library that lets you interact with the Twitter API using easy to use objects and methods. It will work with any of the .NET variants (C#, VB, J#, Windows Forms, ASP.NET, WPF, etc). I added the functionality into the <a href="http://www.360webcms.com/">360 Web Content Management System</a> and I thought I&#8217;d share with you how I did it.</p>
<p><span style="text-decoration: underline;"><strong>Here&#8217;s how to retrieve twitter feeds in ASP.NET</strong></span></p>
<p><strong>(1) Get a copy of the Twitterizer Library </strong></p>
<p>First, you&#8217;ll need to get a copy of the <a href="http://code.google.com/p/twitterizer/">Twitterizer Library from Google&#8217;s Codebase</a>. The download is pretty small and contains only the application library (DLL) you need. Create a new website in ASP.NET and extract the twitterizer library to the /bin/ folder so that you can use it.  Once you have it placed in your /bin/ folder, add a &#8220;using&#8221; reference to the library in the header of your page.</p>
<p>using Twitterizer.Framework;</p>
<p><strong>(2) Create a &#8220;Twitter&#8221; object and Retrieve Your Status Updates.</strong></p>
<p>The library contains a few different objects that you can create. A &#8220;Twitter&#8221; object is the most generic object that you can create. Creating an instance of this object using your username and password gives you all the functionality you would normally have in Twitter, but instead of using the Twitter web interface, you&#8217;re using C# or Visual Basic. First, we&#8217;ll need to instantiate the object, and then get a collection of status updates from your account.</p>
<p>Twitter thisUser = new Twitter(&#8220;UserNameHere&#8221;, &#8220;PasswordHere&#8221;);<br />
TwitterStatusCollection thisCollection = thisUser.Status.UserTimeline();</p>
<p><strong>(3) Loop Through Your Status Updates and Generate Some HTML</strong></p>
<p>The &#8220;TwitterStatusCollection&#8221; object type is a list of &#8220;TwitterStatus&#8221; objects, so you can use a foreach loop and go through your most recent status updates. You&#8217;ll notice in the code below that I also do some basic work with the time of the status update to generate a hyperlink to the page of the status, similar to what Twitter does.</p>
<p>string TwitterCode = &#8220;&#8221;;<br />
foreach (TwitterStatus thisStatus in thisCollection)<br />
{</p>
<p>TimeSpan thisSpan = new TimeSpan();<br />
thisSpan = DateTime.Now.Subtract(thisStatus.Created);</p>
<p>string TimeBetween = &#8220;&#8221;;<br />
if (thisSpan.Days &gt; 0) { TimeBetween = thisSpan.Days.ToString() + &#8221; days ago&#8221;; }<br />
else if (thisSpan.Hours &gt; 0) { TimeBetween = thisSpan.Days.ToString() + &#8221; hours ago&#8221;;}<br />
else if (thisSpan.Minutes &gt; 0) { TimeBetween = thisSpan.Days.ToString() + &#8221; minutes ago&#8221;;}<br />
else if (thisSpan.Seconds &gt; 0) { TimeBetween = thisSpan.Days.ToString() + &#8221; seconds ago&#8221;;}</p>
<p>TwitterCode += &#8220;&lt;div class=&#8217;TwitterStatus&#8217;&gt;&#8221; + thisStatus.Text + &#8221; &lt;a href=&#8217;http://twitter.com/&#8221; + thisStatus.TwitterUser.UserName + &#8220;/status/&#8221; + thisStatus.ID + &#8220;&#8216;&gt;&#8221; + TimeBetween + &#8220;&lt;/a&gt;&lt;/div&gt;&#8221;;<br />
}<br />
<strong>(4) Display Your Tweets </strong></p>
<p>You now have a string with your most recent twitter status updates that you can display on the page using a simple Response.Write() or you can display it in a label. You can see a variation of this code running on the <a href="http://www.360webcms.com/addons/twitter/">&#8220;Twitter&#8221; page for the 360 Web Content Management System</a>.</p>
<p>You can also download a copy of my <a href="http://www.adventuresindevelopment.com/wp-content/uploads/2009/06/twitter.zip">sample code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adventuresindevelopment.com/2009/06/21/how-to-display-your-twitter-feed-using-aspnet/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
