Twitter updates on my sidebar

Sticking some code here because its the easiest place to put it. I promise I have a real blog post sitting in draft status, I just get too distracted by things like this to finish it. :) Anywho, this is the code I used (largely borrowed from Jon Aquino) to put my last 5 twitters (tweets?) in a module over yonder –>
If you use it, be sure to change YOURUSERID to whatever your user id really is. If you don’t know what it is, click the RSS link @ the bottom of your Twitter profile. Your user id is the numbers before the .rss.

&lt;script type="text/javascript"&gt;<br />function twitterCallback(obj) {<br />var html = '';<br />for (var i = 0; i &lt; 5; i++) {<br /> html += '&lt;li&gt;&lt;a href="\"http://twitter.com/'+ obj[i].user.screen_name + '/statuses/' + obj[i].id +'\"&gt;' + obj[i].text +' &lt;/a&gt;&lt;/li&gt;';<br />}<br />document.getElementById('twitter_list').innerHTML = html;<br />}<br />&lt;/script&gt;<br />&lt;ul id="twitter_list"&gt;&lt;/ul&gt;<br />&lt;script src="http://twitter.com/statuses/user_timeline/YOURUSERID.json?callback=twitterCallback&count=5" type="text/javascript"&gt;&lt;/script&gt;

Well there it is. Maybe one day if I’m feeling froggy I’ll make it into a “real” Blogger widget. Don’t hold your breath though. ;)

Update: Fixed so it works with the changes made to Twitters API.

No related posts.

  • jeffy
    Thanks! I like the link back. There's a couple little problems with this code as posted, though. the " before the \"http shouldn't be there, and the </li> should be swapped.
    Otherwise works great.
  • Erica Joy
    Good call jeffy! I've changed around the /li and the /a. Unfortunately blogger pitches a fit and changes all the code around if I don't put the quotation mark before the \. After looking @ the module again, it seems that the quotation mark before the http got stripped out anyhow so what it really wanted was "\http. Very weird. I'll try to look into it. :)
  • bnycastro
    hi erica new to twitter and i"d like to thank ya for this 5 tweet code you provided. greets from manila, philippines
blog comments powered by Disqus