As Twitter's popularity continues to increase, users and consumers of the information being broadcast are looking for quick and easy ways to integrate some of the information into their own content. So I whipped up this short, but sweet, example of how easy it is to repurpose content from Twitter using just a dash of ColdFusion.
First things first though, what makes consuming information from Twitter so easy is their search functionality. Check it out at http://search.twitter.com. By following the instructions there, you will see that anything you search for can be "burned" via RSS. After your search, following the link "Feed for this query" and viola! Instant RSS feed you can now consume. How sweet it is.
What's really cool is that if you search for let's say "stevewithington" you can see not only my posts, but also any responses too. If you only want to see tweets "from" me for example, then you simply put "from:" in front of your search criteria such as "from:stevewithington."
For sake of simplicity, I'm going to just follow the "Feed for this query" link and continue on.
If you're using ColdFusion 8, then all you have to do is use CFFeed to consume the feed. Here's a sample line of code:
<cfset feedurl="http://search.twitter.com/search.atom?q=from%3Astevewithington" />
If you're curious as to what the feed contains, you can always use CFDump to find out:
<cfdump var="#feeditems#" label="feedItems" />
Using the above line of code, you should see something similar to the following:
As you'll see, CFFeed creates a very nice query object containing quite a bit of information for you. One field of interest at this point is the "CONTENT" field which contains HTML-formatted code for each tweet. If you prefer a "text-only" version of the tweet, then simply use the "TITLE" field. So, to show how easy this is, let's just loop over the feed items and output the "CONTENT."
Running the above line of code, you should see something like this:
I know, I know, you're probably thinking, "there's got to be more to it, right?" Well, there is if you want there to be! Using CFDump, you saw all kinds of information you can repurpose to your heart's desire. Think up new ways to use Twitter and with ColdFusion's CFFeed you can create new ways to consume it's easy-to-integrate-and-embed information.