Step-by-Step: Twitter Integration in SharePoint 2010

Written by Denis Stadler on . Posted in SharePoint 2010

In order to display Twitter Feed in SharePoint 2010 I will use a build in web part – XML Viewer. First we will add this web part in our page from Share Point graphic interface ( Site Actions -> Edit Page -> Add a Web Part ).

Then just click open the tool pane in the new added web part.

The tool pane is now open. There are two things here to configure:

  • XML Link
  • XSL Display Template

Configuring the XML Link is the easy part. Just add:

http://twitter.com/statuses/user_timeline/<your-twitter-user>.xml?count=3

The value of the count query string parameter is the number of tweets to be displayed.  If you need more info about the Twitter user_timeline API please follow the link.

Click XSL Editor and add the following code:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html" indent="yes" />
<xsl:template match="/">

<!-- foreach item in /statuses/status -->
<xsl:for-each select="/statuses/status">

<!-- header: add name, profile pic, location, description -->
<xsl:if test="count(preceding-sibling::*)=0">
<table>
<tr>
<td><img src="{user/profile_image_url}" /></td>
<td><a href="http://twitter.com/{screen_name}" target="_blank">
<xsl:value-of select="user/name" /></a>
<br/>
<xsl:value-of select="user/description" />
<br/>
<xsl:value-of select="user/location" />
</td>
</tr>
</table>
</xsl:if>

<!--repeater details -->

- <xsl:value-of select="text" /><br/>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

You can download the full Twitter XML Viewer Web Part XSL code.

So this is it!

Update 09.05.2012

If you want to add a Twitter follow button, follow the steps:

  • generate your button code on Twitter – Follow Button web page:
  • paste your code in the XML above just before the </xsl:template> tag.

This is it!


Update 10.01.2013

Thank you PaulE for pointing it out!

Twitter API v1.0 will be turned off March 5, 2013. You can find more details here – FAQ | Twitter Developers.

The documentation of GET statuses/user_timeline for 1.1 API says that every request has to be authenticated using OAuth. This means that we have to create a twitter app and then embed into our code the app keys etc.

So probably the fastest way to integrate the Twitter feed into SharePoint, after 5 March 2013, it will be by using an embedded timeline.

Tags: , , ,

Trackback from your site.

Denis Stadler

I'm a technology enthusiast, with more than 10 years of experience in SharePoint and Dynamics CRM projects. To find more details about, please visit the about me page.

Comments (27)

  • Jason Mealing

    |

    Like the twitter feed on SharePoint 2010 real nice. One question is there a way of putting in the date of the twitter posts?

    Reply

    • Denis Stadler

      |

      For example add xsl:value-of select=”created_at” after xsl:value-of select=”text” tag in the XSL and it should work.

      Reply

      • Jason Mealing

        |

        Thanks for that. I know I am being a bit of a dummy here but I get day month time then “+0000″ and the date. Have you any ideas why that “+0000″ would be appearing?

        Reply

  • Maria Macaluso

    |

    Hi There – This didn’t seem to work for me. I added this URL into the XML Link section and it did open up a our Twitter feed though:

    https://twitter.com/intent/user?screen_name=theNETXperts

    Obviously “theNETXperts” is our screen name. Now I just need to figure out how to adjust the formatting. Any ideas? When I add the XSL code, it reads an error message.

    Reply

  • George Lu

    |

    This is a great guide for a Twitter feed web part. Do you have a guide for creating a “Follow @screen_name” web part? Thanks.

    Reply

      • George Lu

        |

        Hi Denis,

        Is it possible to make the URLs in the tweets as hyperlinks?

        Thanks.

        Reply

          • George Lu

            |

            Thanks Denis. I’ve got this code from the web. How can I make it work in this XSL?

            (code removed from here)

            Reply

          • Denis Stadler

            |

            Could you send me the entire code (both this and your XSL) at denis[at]stadler.pro?

            Reply

  • George Lu

    |

    Thanks Denis. Excellent update! One question: is it possible to change the look & feel of the button?

    Reply

    • Denis Stadler

      |

      I don’t know if the code which is generated in the Twitter – Follow button page cand be modified. I haven’t tried that.

      Reply

  • Jennifer Hart

    |

    I added the link “http://twitter.com/statuses/user_timeline/CityofWichita.xml?count=3″ to the XML Link field and tested the link. It worked. Then I copied/pasted the code for the XSL Editor. Now I get the message “Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator.” I have not modified any of the code.

    Reply

    • Denis Stadler

      |

      I have tried using your Twitter link and it works fine. Could you just try one more time?

      Reply

  • uShed

    |

    Hi Denis. can you provide an update on how to make any URL’s in the feed hyperlinked please? Thanks for the code

    Reply

    • Denis Stadler

      |

      It seems that the Twitter API used in this page, doesn’t provide the information as links. I’ll take a closer look and publish and answer.

      Reply

  • David

    |

    Same as above….its not working

    Sharepoint sever 2010

    I know you say you get everyones to work when you do it, but when everyone else does it on there systems, it does not work. please help

    Reply

    • Denis Stadler

      |

      Thank you for pointing it out! Probably the fastest way to integrate the Twitter feed into SharePoint, it will be by using an embedded timeline.

      Reply

Leave a comment

*