Add your Latest Tweet to DotNetNuke, Including Retweets

To add your latest tweet to a DotNetNuke website, simply add the following HTML to your skin templates.

<div id="twitter">
 <ul id="twitter_update_list"></ul>
 — <a id="twitter_link" href="http://twitter.com/USERNAME">@USERNAME</a>
 </div>
 <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript"></script>
 <script src="http://api.twitter.com/1/statuses/user_timeline.json?callback=twitterCallback2&screen_name=USERNAME&count=1&include_rts=true" type="text/javascript"></script>
</div>

Just replace USERNAME with your twitter username.

Technical Details

This approach uses the Twitter User Timeline API to pull in the latest tweet as a JSON object. A function in the blogger.js script is then used to parse the JSON and insert it into the twitter_update_list element.

Add some CSS magic to the twitter div and you have a very easy, client side solution for pulling, parsing and then publishing your latest tweet.

Include Retweets

Notice the include_rts=true parameter being sent to the user_timeline.json script?

That tells twitter to include retweets. Without it, you’ll end up with an empty value when your latest tweet is a retweet.

Further Reading

Special thanks to Isabella Snow and Blogger Buster for their articles. They refer to the old Twitter API but still provide a great starting point.

For more information about what else you can get from the Twitter API, see the full Twitter User Timeline API documentation.

About Brent

Born to code.
This entry was posted in Blogdex and tagged , , . Bookmark the permalink.