i blog often

general 7 March 2007 | View Comments

but i twitter often-er.

Last night i was having one of my “cant sleep, must code” fits and decided to whip up my own version of a twitter sidebar widget. Now, on the right of every page, you’ll see “what i’m thinking” followed by a short burst of thought.

Twitter, for those of you somehow unfamiliar, finds a happy medium between stream of conscious and blogging. In this particular case, i have 140 characters to answer the question, “what are you doing right now”. The really cool part is it’s updatable via SMS, AIM/GTalk/Jabber, or the REST interface provided in their API. So you get microblogging, on the run.

Anyway, my little mash together utilizes the twitter personal feed, and SimplePie for mega-simple feed parsing.

Code example after the break.

  1. <?php
  2. require('simplepie.inc');
  3. $feed = new SimplePie();
  4. $feed->feed_url('http://twitter.com/statuses/user_timeline/8412.rss');
  5. $feed->cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
  6. $feed->init();
  7. $feed->handle_content_type();
  8. if ($feed->data) {
  9. $max = $feed->get_item_quantity(1);
  10. for ($x = 0; $x < $max; $x++) {
  11. $item = $feed->get_item($x);
  12. ?>
  13. <p><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></p>
  14. <?
  15. }
  16. }
  17. ?>

[tags]twitter, simplepie, mashup[/tags]

Bookmark and Share

Tagged in

Leave a Reply

blog comments powered by Disqus