Twitter on SharePoint 

Tags: How To, Social, Pre SharePoint 2010, SharePoint Designer

Showing a list of Twitter.com tweets from a Twitterer on SharePoint is as easy as pasting some HTML and Javascript into a Content Web Part, available in WSS. I created a family Twitter account because sometimes blog entries are just too much to say, the baby now weighs 10 pounds. I had initially considered making a simple SharePoint list and presenting items that way, but then settled leveraging Twitter and all its extra functionality. The one drawback is if Twitter is down or goes away completely.

I first tried consuming the Twitter RSS feed using a Dataview web part and SharePoint Designer, but fortunately (sic), I had some trouble figuring out how to display the tweet times in my local time zone, EST or GMT -0500. The RSS delivers the tweet times in GMT +0000, e.g., Tue, 18 Nov 2008 23:13:20 +0000. I found some XSLT to deal with it (http://ftrain.com/xslt_001.html is overkill), but it was messier than I cared to deal with.

Then I found http://twitter.com/badges/which_badge where you can choose Flash, or HTML + Javascript, which is what I chose (http://twitter.com/badges/html). As the Twitter badge page suggests, I broke the code apart, putting the

<ul id="twitter_update_list"></ul>

into one content web part, and putting the two Javascript lines

<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>

<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/FamilySite.json?callback=twitterCallback2&amp;count=5"></script>

 

into the very bottom, right-most zone so that it would load last, and not prevent the rest of the page from loading if Twitter is slow or absent. I kind of liked the "follow me on Twitter" link that they show in the preview on the badge page. For whatever reason, this link is missing from the HTML code, but this line

<a href="http://twitter.com/FamilySite" id="twitter-link">follow us on Twitter</a>

fixes the problem.

On the home page, at my wife's request, our tweets are now front and center at the top of the page. It shows a maximum of seven tweets. However, the code snippet has count as a parameter. I used a different account which already had lots of tweets, and was able to get 45 at once. So from the home page's content, I linked to a new web part page that shows up to 150 of our tweets. I figure beyond that, the page is going to be too long. This is one big advantage over RSS which appears to support a maximum of just 20.

A peek under the hood of the Javascript reveals Javascript + JSON fetching and presenting the data. It appears that one could easily customize the strangely named blogger.js. You could present some different looks like actual date & time (beware the time zone offset mentioned in the 2nd paragraph) and add in some of the non-presented AJAX content such as the Twitter image and number of followers.

 
Posted by AndyGett on 4-Jan-09
0 Comments  |  Trackback Url | Bookmark this post with:        
 

Comments

Name:
URL:
Email:
Comments: