Future of Web Apps Miami - Conference 22-24 February 2010

News Flash

Want to make extra cash? We'll give you $20 for every ticket you sell to the CSS3 Conference. Yay! http://bit.ly/9nD2SM

Blog:

20 January 2009

How to Create an RSS-Enabled, Micro-Blog with Twitter

By Ryan Carson

Have you ever wanted to create a simple multi-person blog, but didn’t want to bother setting up an entire WordPress installation? If so then we’ve got just the answer. By combining Twitter Search, Atom feeds, hash-tags and PHP, you can create an RSS-enabled, micro-blog using Twitter and be up and running in less than 10 minutes.

The new Think Vitamin news feed is powered this way, so let me show you how we built it.

Screenshot of the Think Vitamin news feed

Sign up for Twitter

First off, make sure you and the other blog contributors have Twitter accounts. It’s free and only takes two minutes to sign up.

Choose your Hash-Tag

The way you will post to the blog is by including a ‘hash-tag’ in your Twitter post. For example, we chose #thinkvitamin for the news feed. It can be anything, but make sure it’s not too common so you don’t pull in Tweets that are irrelevant (ie #strawberries or #obama). A great way to check is to search for potential hash-tags at search.twitter.com and see how many times they’re used. The fewer the better.

Create Your Atom Feed

Head over to search.twitter.com and type the following into the search bar:

#your-hash-tag from:user01 OR from:user02 OR from:user03

Replace ‘your-hash-tag’ with the hash-tag you’ve chosen, and ‘user01′, ‘user02′ and ‘user03′ with the Twitter usernames of the folks who have permission to contribute to the blog. You can include as many Twitter usernames as you like.

This will return results from user01 or user02 or user03 where the hash-tag ‘#your-hash-tag’ was used. Now copy the ‘Feed for this query’ link to your clipboard (you’ll need it later).

Output the Atom Feed as HTML

You can use PHP (or any language of your choice) to parse the feed and output it to a page as HTML. This is where you’ll need the feed URL you copied in the last step.

The file atom-html.php (download the source) outputs certain nodes of the Atom feed as list items in an unordered list. You can then style this list however you like. Here is an example of how to implement the code:


<ul>
<?php
include('atom-html.php');

# The URL for the Atom feed from search.twitter.com
$url = “http://search.twitter.com/search.atom?q=
%23your-hash-tag+from%3Auser01+OR+from%3Auser02+OR+from%3Auser03″;

# Create object to hold data and display output
$atom_parser = new myAtomParser($url);

# Return string containing HTML. The argument for getOutput() is the
# number of items to display
$output = $atom_parser->getOutput(5);
echo $output;
?>
</ul>

Count the Subscribers with FeedBurner

It’s important to know how many subscribers you have, so make sure to pipe the Atom feed (that you created in the ‘Create Your Atom Feed’ above) through FeedBurner. If you don’t have an account, it’s free and easy to sign up.

Once you have a URL from FeedBurner for your feed, make sure to include it as the ‘Subscribe’ link in the HTML.

What About Comments?

We haven’t enabled any commenting on the Think Vitamin news feed, but this could be added by including a Disqus snippet in the HTML output.

That’s it.

We told you it was easy. Let us know if you’re currently using Twitter on any of your sites in an interesting way.

304
FOWA Miami banner ad

304 Comments

Have your say:

Subscribe to our Newsletter

Sign up to the Think Vitamin Newsletter to get updates on web design, web development and web entrepreneurship as well as special offers and discounts from Carsonified. Rest assured we never share your email address.

Subscribe to the Think Vitamin articles RSS feed

Future of Web Apps Miami - Conference 22-24 February 2010

News

Twitter

Follow us on Twitter

Subscribe

Article Subscribers

Feedburner blog subscriber indicator

News Subscribers

Feedburner blog subscriber indicator

Subscribe by Email

You can receive Think Vitamin updates via email. Just pop your email address in the box below and click the arrows.

Subscribe by RSS

You can also receive new Think Vitamin posts via your RSS feed reader

Subscribe RSS Think Vitamin is a proud member of the Smashing Network

Ads Via The Deck