Skip to content
ziyasal edited this page Dec 11, 2012 · 2 revisions

Basic Usage

Add following configuration to appSettings below web.config file

<add key="Tw-ApiKey" value="your consumer key here"/>
<add key="Tw-AppSecret" value="your consumer secret here"/>
<add key="Tw-RedirectUri" value="your redirected uri here"/>
  1. Setup Authentication Link (Button)

Markup

 <a href='http://twitter.com/oauth/authorize?<%=GetUrlParamters()%>'>Login with Twitter</a>

Code Behind

protected string GetUrlParamters()
{
    ITwitterOAuthManager oAuthManager = new TwitterOAuthManager();
    return oAuthManager.GetUrlParameters();
 }
  1. After Twitter redirected to referrer url, Redirected page code behind
protected void Page_Load(object sender, EventArgs e)
{
     ITwitterOAuthManager oAuthManager = new TwitterOAuthManager();

     if (oAuthManager.CheckTwitterOAuthRequest(Request.QueryString))
     {
          TwitterBasicProfile result = oAuthManager.Authenticate(Request.QueryString);
          txtHtmlArea.InnerHtml = Server.HtmlEncode(result.ScreenName);
     }
}

Redirected page markup

<div id="txtHtmlArea" runat="server"></div>
Clone this wiki locally