Ajax Control Toolkit
Twitter Demonstration
Displays status messages (tweets) for a Twitter account:



Displays status messages (tweets) for a Twitter account using a custom LayoutTemplate and StatusTemplate:

Displays Twitter search results for ASP.NET:



Twitter Description

The Twitter control is an ASP.NET AJAX control that enables you to display Twitter status messages (tweets) from Twitter.com. This control has two modes: Profile and Search. In Profile mode, you can display the latest tweets from a particular user by supplying the user's Twitter screen name. In Search mode, you can display all tweets which match a search query.


Twitter limits the number of times that you can interact with their API in an hour. Twitter recommends that you cache results on the server (https://dev.twitter.com/docs/rate-limiting). By default, the Twitter control caches results on the server a duration of 5 minutes. You can modify the cache duration by assigning a value (in seconds) to the Twitter control's CacheDuration property.


The Twitter control wraps a standard ASP.NET ListView control. You can customize the appearance of the Twitter control by modifying its LayoutTemplate, StatusTemplate, AlternatingStatusTemplate, and EmptyDataTemplate.


Twitter Properties
<ajaxToolkit:Twitter 
            Mode="Profile"
            ScreenName="ScottGu" 
            runat="server" />
  • Mode - either Profile or Search mode.
  • ScreenName - required in Profile mode. The Twitter user to display.
  • Search - required in Search mode. The search to perform. You can build complex queries with search operators
  • Count - number of status messages (tweets) to display. The default value is 5.
  • CacheDuration - amount of time to cache results from Twitter in seconds. The default value is 300 seconds.
  • IncludeRetweets - in Profile mode, indicates whether retweets are displayed.
  • IncludeReplies - in Profile mode, indicates whether replies are displayed.
  • LayoutTemplate - template which contains the HTML for the root container of the ListView content.
  • StatusTemplate - template which contains each status message (tweet).
  • AlternatingStatusTemplate - template which is applied for alternating status messages (tweets).
  • EmptyDataTemplate - template which displays content when there are no tweets.
  • Title - enables you to display title text in the header. In Profile mode, the default value is the full user name.
  • Caption - enables you to display caption text in the header. In Profile mode, the default value is the user screen name.

AjaxControlToolkit Twitter Control using Twitter API v1.1. The Twitter API v1.1 requiring us to provide API keys which are Consumer Key, Consumer Secret, Access token and Access token secret. You will need to create those keys through https://dev.twitter.com/apps/new and supply those information into your web config under appSettings tag. It should looks like this:

 

<appSettings>

   <add key="act:TwitterConsumerKey" value="[Your consumer key]"/>

   <add key="act:TwitterConsumerSecret" value="[Your consumer secret]"/>

   <add key="act:TwitterAccessToken" value="[Your access token]"/>

   <add key="act:TwitterAccessTokenSecret" value="[Your token secret]"/>

</appSettings>

 

For more information about Twitter API v1.1 you can find in https://dev.twitter.com/docs/api/1.1/overview.

Copyright © 2006-2013 Microsoft Corporation. All Rights Reserved.