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.
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. This means we can simply use CFFeed to consume Tweets!
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 here's a short, but sweet, example of how easy it is to repurpose content from Twitter using just a dash of ColdFusion.
As long as you're using ColdFusion 8+, 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"
/>
<cffeed
source=
"#feedurl#"
properties=
"feedmeta"
query=
"feeditems" />
If you're curious as to what the feed contains, you can always use CFDump to find out:
<cfdump var= "#feeditems#" label= "feedItems" />
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."
1:
<cfset feedurl=
"http:
//search.twitter.com/search.atom?q=from%3Astevewithington"
/>
2:
<cftry>
3:
<cffeed source=
"#feedurl#" properties=
"feedmeta" query=
"feeditems" />
4:
<ol>
5:
<cfoutput query=
"feeditems">
6:
<li>#feeditems.content#
</li>
7:
</cfoutput>
8:
</ol>
9:
<cfdump var=
"#feeditems#" label=
"feedItems" />
10:
<cfcatch>
11:
<cfoutput>
12:
Something
went wrong at Twitter.
13:
</cfoutput>
14:
</cfcatch>
15:
</cftry>
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. With ColdFusion's CFFeed you can create new ways to consume any kind of RSS and turn it into easy-to-integrate-and-embed information.
To see the original article as posted on my blog, please visit http://www.stephenwithington.com/blog/index.cfm/2009/3/4/Use-ColdFusions-CFFeed-to-Display-Your-Twitter-Tweets-and-more-on-Your-Blog-in-30-Seconds
+