32 votes

Twitter for Umbraco

This has been confirmed to work with version 4.5 of Umbraco

Description

This package allows you to display your recent tweets from Twitter.

 

New in Version 2.0

  • [Lee K] Added Twitter Search macro.
  • [Lee K] Added .NET controls to embed tweets directly into your website (a la Blackbird Pie).
  • [Warren B] Updated Twitter Status XSLT with new Twitter REST API to fix long load times

New in Version 1.6

 

  • Use the NEW Twitter API
  • Support for enabling/disabling native RTs in the stream

New in Version 1.5

  • Google Static Maps API no longer needs an API key so this macro parameter has been removed
  • Better commenting of XSLT file
  • Few tiny tweaks to markup
  • Verified to work with Umbraco version 4.5
  • Fixed bug - When showing only your tweets and limiting to a specific number. Where before if your last 5 tweets were @replies nothing would be displayed.

Installation

  1. Download the package (zip file) to your machine
  2. Login to your umbraco install and goto the developer section
  3. Expand the packages folder
  4. Select install local package and point to zip file you just downloaded
  5. Wait for the install to finish
  6. Insert the [XSLT] CWS - Twitter macro into your template
  7. Fill in parameters for the macro
  8. Ammend the XSLT to suit your XHTML needs
  9. VOILA - Your done !

Installs the following files

  • bin/CWS.Twitter4Umbraco.XSLTExtensions.dll
  • xslt/CWS_twitter.xslt

The actual package installs the following into umbraco:

  • Macro: [XSLT] CWS - Twitter
  • XSLT: CWS_twitter.xslt
  • Registers the DLL as an XSLT Extension in /config/XSLTExtensions.config

Macro Parameters

  • Twitter Username - Your twitter username of the account you wish to display tweets from
  • Number of Statuses - The number of statuses you want to display (Upto 200)
  • Display @ Replies? - If you wish to show tweets, where you are replying to a user
  • Display Google Maps? - If you wish to display google maps for geo encoded tweets
  • Google Maps - Zoom Level - Zoom level of the map (0 to 21)
  • Google Maps - Map Size - Size of the map in pixels (eg: 500x500)
  • Google Maps - Map Type - The type of map (roadmap, satellite, hybrid ,terrain)

For info about the Google Static Maps API
http://code.google.com/apis/maps/documentation/staticmaps/

 

Editing the markup

Open up CWS_twitter.xslt and edit only the markup inside this template:

<xsl:template match="status" mode="tweet">  <!-- Change the XHTML here for how you want each tweet to be displayed -->  <div>    <p>      <img src="{user/profile_image_url}" />      <strong>        <xsl:value-of select="user/name"/>      </strong>      -      <xsl:value-of select="umbraco.library:FormatDateTime(CWS.Twitter:FormatTwitterDate(created_at), 'ddd d MMM yy @ H:mm')"/>      <xsl:value-of select="CWS.Twitter:FormatUrls(text)" disable-output-escaping="yes"/>    </p>    <!-- Show Map of Tweet - IF value there & user enabled maps -->    <xsl:if test="geo/georss:point != '' and $displayMaps = 1">      <p>        <!-- Pass coordinates to map template-->        <xsl:call-template name="map">          <!-- Google wants coordinates as comma seperated so replace (space) with comma -->          <xsl:with-param name="coordinates" select="umbraco.library:Replace(geo/georss:point,' ',',')" />        </xsl:call-template>      </p>    </xsl:if>  </div></xsl:template>

 

Example Status XML

If you wish to add further fields to your output I have included below a copy of the XML that twitter returns for each tweet.

Example Status XML - Geo

Below is an example of the XML that twitter returns for each tweet with additional Geo information

<status>  <created_at>Wed Aug 25 19:40:45 +0000 2010</created_at>  <id>22113974549</id>  <text>Sending out a geo tagged tweet as a test to update the twitter for #umbraco package to the new API from twitter</text>  <source>&lt;a href=&quot;http://twitter.com/&quot; rel=&quot;nofollow&quot;&gt;Twitter for iPhone&lt;/a&gt;</source>  <truncated>false</truncated>  <in_reply_to_status_id></in_reply_to_status_id>  <in_reply_to_user_id></in_reply_to_user_id>  <favorited>false</favorited>  <in_reply_to_screen_name></in_reply_to_screen_name>  <retweet_count></retweet_count>  <retweeted>false</retweeted>  <user>    <id>9751992</id>    <name>Warren Buckley</name>    <screen_name>warrenbuckley</screen_name>    <location>iPhone: 51.559616,0.592538</location>    <description>A web developer who is based in the UK that works for Norwegian Web Agency Xeed - http://www.xeed.no</description>    <profile_image_url>http://a3.twimg.com/profile_images/696762619/warren-buckley_normal.jpg</profile_image_url>    <url>http://www.creativewebspecialist.co.uk</url>    <protected>false</protected>    <followers_count>557</followers_count>    <profile_background_color>022330</profile_background_color>    <profile_text_color>333333</profile_text_color>    <profile_link_color>0084B4</profile_link_color>    <profile_sidebar_fill_color>C0DFEC</profile_sidebar_fill_color>    <profile_sidebar_border_color>a8c7f7</profile_sidebar_border_color>    <friends_count>257</friends_count>    <created_at>Sun Oct 28 11:44:59 +0000 2007</created_at>    <favourites_count>974</favourites_count>    <utc_offset>0</utc_offset>    <time_zone>London</time_zone>    <profile_background_image_url>http://s.twimg.com/a/1282351897/images/themes/theme15/bg.png</profile_background_image_url>    <profile_background_tile>false</profile_background_tile>    <profile_use_background_image>true</profile_use_background_image>    <notifications>false</notifications>    <geo_enabled>true</geo_enabled>    <verified>false</verified>    <following>true</following>    <statuses_count>7772</statuses_count>    <lang>en</lang>    <contributors_enabled>false</contributors_enabled>    <follow_request_sent>false</follow_request_sent>    <listed_count>55</listed_count>    <show_all_inline_media>false</show_all_inline_media>  </user>  <geo xmlns:georss="http://www.georss.org/georss">    <georss:point>51.5596798 0.59269702</georss:point>  </geo>  <coordinates xmlns:georss="http://www.georss.org/georss">    <georss:point>51.5596798 0.59269702</georss:point>  </coordinates>  <place xmlns:georss="http://www.georss.org/georss">    <id>433a0c1e74bddb9e</id>    <name>Castle Point</name>    <full_name>Castle Point, Essex</full_name>    <place_type>city</place_type>    <url>http://api.twitter.com/1/geo/id/433a0c1e74bddb9e.json</url>    <attributes/>    <bounding_box>      <georss:polygon>51.500769 0.5157113 51.500769 0.703401 51.5877718 0.703401 51.5877718 0.5157113</georss:polygon>    </bounding_box>    <country code="">United Kingdom</country>  </place>  <contributors/></status>

 

Example Status XML - Native RT

Below is an example of the XML that twitter returns for each tweet with additional RT information

<status>  <created_at>Wed Aug 25 19:20:30 +0000 2010</created_at>  <id>22112745181</id>  <text>RT @leekelleher: Any #umbraco devs want to help on an ELMAH package? Need help with package action, (not enough hours in the day!) http: ...</text>  <source>&lt;a href=&quot;http://www.tweetdeck.com&quot; rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;</source>  <truncated>true</truncated>  <in_reply_to_status_id></in_reply_to_status_id>  <in_reply_to_user_id></in_reply_to_user_id>  <favorited>false</favorited>  <in_reply_to_screen_name></in_reply_to_screen_name>  <retweet_count></retweet_count>  <retweeted>false</retweeted>  <retweeted_status>    <created_at>Wed Aug 25 17:16:13 +0000 2010</created_at>    <id>22105108358</id>    <text>Any #umbraco devs want to help on an ELMAH package? Need help with package action, (not enough hours in the day!) http://bit.ly/9nu4G0</text>    <source>&lt;a href=&quot;http://www.twhirl.org&quot; rel=&quot;nofollow&quot;&gt;Seesmic twhirl&lt;/a&gt;</source>    <truncated>false</truncated>    <in_reply_to_status_id></in_reply_to_status_id>    <in_reply_to_user_id></in_reply_to_user_id>    <favorited>false</favorited>    <in_reply_to_screen_name></in_reply_to_screen_name>    <retweet_count></retweet_count>    <retweeted>false</retweeted>    <user>      <id>1005461</id>      <name>Lee Kelleher</name>      <screen_name>leekelleher</screen_name>      <location>Yatton, Bristol, UK</location>      <description>Umbraco MVP 2010 and ASP.NET developer.</description>      <profile_image_url>http://a2.twimg.com/profile_images/56197478/northbynorthwest_300x300_normal.jpg</profile_image_url>      <url>http://leekelleher.com/</url>      <protected>false</protected>      <followers_count>306</followers_count>      <profile_background_color>709397</profile_background_color>      <profile_text_color>333333</profile_text_color>      <profile_link_color>1F98C7</profile_link_color>      <profile_sidebar_fill_color>A0C5C7</profile_sidebar_fill_color>      <profile_sidebar_border_color>86A4A6</profile_sidebar_border_color>      <friends_count>184</friends_count>      <created_at>Mon Mar 12 12:29:59 +0000 2007</created_at>      <favourites_count>2</favourites_count>      <utc_offset>0</utc_offset>      <time_zone>London</time_zone>      <profile_background_image_url>http://a3.twimg.com/profile_background_images/88106321/shark.jpg</profile_background_image_url>      <profile_background_tile>true</profile_background_tile>      <profile_use_background_image>true</profile_use_background_image>      <notifications>false</notifications>      <geo_enabled>true</geo_enabled>      <verified>false</verified>      <following>false</following>      <statuses_count>2735</statuses_count>      <lang>en</lang>      <contributors_enabled>false</contributors_enabled>      <follow_request_sent>false</follow_request_sent>      <listed_count>50</listed_count>      <show_all_inline_media>false</show_all_inline_media>    </user>    <geo/>    <coordinates/>    <place/>    <contributors/>  </retweeted_status>  <user>    <id>9751992</id>    <name>Warren Buckley</name>    <screen_name>warrenbuckley</screen_name>    <location>iPhone: 51.559616,0.592538</location>    <description>A web developer who is based in the UK that works for Norwegian Web Agency Xeed - http://www.xeed.no</description>    <profile_image_url>http://a3.twimg.com/profile_images/696762619/warren-buckley_normal.jpg</profile_image_url>    <url>http://www.creativewebspecialist.co.uk</url>    <protected>false</protected>    <followers_count>557</followers_count>    <profile_background_color>022330</profile_background_color>    <profile_text_color>333333</profile_text_color>    <profile_link_color>0084B4</profile_link_color>    <profile_sidebar_fill_color>C0DFEC</profile_sidebar_fill_color>    <profile_sidebar_border_color>a8c7f7</profile_sidebar_border_color>    <friends_count>257</friends_count>    <created_at>Sun Oct 28 11:44:59 +0000 2007</created_at>    <favourites_count>974</favourites_count>    <utc_offset>0</utc_offset>    <time_zone>London</time_zone>    <profile_background_image_url>http://s.twimg.com/a/1282351897/images/themes/theme15/bg.png</profile_background_image_url>    <profile_background_tile>false</profile_background_tile>    <profile_use_background_image>true</profile_use_background_image>    <notifications>false</notifications>    <geo_enabled>true</geo_enabled>    <verified>false</verified>    <following>true</following>    <statuses_count>7771</statuses_count>    <lang>en</lang>    <contributors_enabled>false</contributors_enabled>    <follow_request_sent>false</follow_request_sent>    <listed_count>55</listed_count>    <show_all_inline_media>false</show_all_inline_media>  </user>  <geo/>  <coordinates/>  <place/>  <contributors/></status>

 

Example Status XML - Previous versions

Below is an example of the XML that twitter returns for each tweet with previous versions (Older than version 1.6)

<status>  <created_at>Wed Dec 09 10:45:26 +0000 2009</created_at>  <id>6493042759</id>  <text>Test tweet to check how geo info is stored Twitter XML.</text>  <source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</source>  <truncated>false</truncated>  <in_reply_to_status_id></in_reply_to_status_id>  <in_reply_to_user_id></in_reply_to_user_id>  <favorited>false</favorited>  <in_reply_to_screen_name></in_reply_to_screen_name>  <user>    <id>9751992</id>    <name>Warren Buckley</name>    <screen_name>warrenbuckley</screen_name>    <location>iPhone: 51.559616,0.592538</location>    <description>A web developer who is based in the UK that works for Norwegian Web Agency Xeed - http://www.xeed.no</description>    <profile_image_url>http://a1.twimg.com/profile_images/63253002/warren-buckley_normal.jpg</profile_image_url>    <url>http://www.creativewebspecialist.co.uk</url>    <protected>false</protected>    <followers_count>426</followers_count>    <profile_background_color>B2DFDA</profile_background_color>    <profile_text_color>333333</profile_text_color>    <profile_link_color>93A644</profile_link_color>    <profile_sidebar_fill_color>ffffff</profile_sidebar_fill_color>    <profile_sidebar_border_color>eeeeee</profile_sidebar_border_color>    <friends_count>211</friends_count>    <created_at>Sun Oct 28 11:44:59 +0000 2007</created_at>    <favourites_count>393</favourites_count>    <utc_offset>0</utc_offset>    <time_zone>London</time_zone>    <profile_background_image_url>http://s.twimg.com/a/1260214487/images/themes/theme13/bg.gif</profile_background_image_url>    <profile_background_tile>false</profile_background_tile>    <statuses_count>5252</statuses_count>    <notifications>false</notifications>    <geo_enabled>true</geo_enabled>    <verified>false</verified>    <following>false</following>  </user>  <geo xmlns:georss="http://www.georss.org/georss">    <georss:point>51.559618 0.592546</georss:point>  </geo></status>

 

Videos

Version 1.6 (Latest)

Refer to the version 1.5 videos, as 1.6 is only a minor release that adds an extra Macro parameter to allow you to enable/disable showing native RTs

Version 1.5

YouTube - http://www.youtube.com/watch?v=jtGHN4ULKsI
Vimeo - http://vimeo.com/13492803

Version 1.4

YouTube - http://www.youtube.com/watch?v=3g_7JDCuj-A
Vimeo - http://vimeo.com/8168025

Screenshots

Project owner

Warren Buckley

Warren Buckley

Warren has 4398 karma points

Project Compatibility

This project is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (0%)
6.0.x (untested)

You must login before you can report on package compatibility.

Project Information

  • Project owner: Warren Buckley
  • Contributors: Morten Bock , Lee Kelleher
  • Created: 25/06/2009
  • Current version 2.0
  • License MIT
  • Downloads: 9976

External resources