MinTwit is a Twitter library for WinRT based apps(Metro style) for Windows 8, written in C#. The current version provides -
- OAuth Authentication.
- Update Status aka tweet.
- Get User Timeline.
- Search for hashtags/terms etc.
NOTE 1: For information about creating a desktop application for Twitter, visit the Twitter Developers Site
NOTE 2: The Async functions return an awaitable Task<T>
value. For more info read Diving deep with WinRT and await
- Prerequisites
-
In VS, Add a reference to the file MinTwit.dll
-
Import the namespace "MinTwit" in your project.
using MinTwit;
-
Create an application for Twitter and use "oob" as the callback url.
-
The ConsumerKey and ConsumerSecret that you'll get shall be used later.
-
Authentication
MinTwit uses 3 step PIN based OAuth to provide authorized access to Twitter's API. The process is fairly simple -
//1. Send out a request for getting an OAuth RequestToken -
//Provide your ConsumerKey
OAuthToken RequestToken = new OAuthToken();
RequestToken = await OAuthControls.GetRequestTokenAsync(string ConsumerKey, string ConsumerSecret);
//2. Get the authorization URL from the RequestToken as follows -
Uri auth_uri = await OAuthControls.GetAuthURLAsync(OAuthToken TwitterRequestToken);
//3. Navigate to the auth_uri via a Launcher
var success = await Windows.System.Launcher.LaunchUriAsync(auth_uri);
if(success)
{
//code to provide the user a way to input the PIN code shown on the browser
}
//4. Exchange the RequestToken with an AccessToken
OAuthToken AccessToken = await OAuthControls.ExchangeRequestWithAccessTokenAsync(string ConsumerKey, string ConsumerSecret, OAuthToken RequestToken, string pin);
- Post Status Updates
string response = await Twitter.Post_status(TweetBox.Text);
Updating status provides a response message on success as given here. You can use the JSON.NET library by James Newton-King for parsing JSON.
- Get User Timeline
string response = await TwitterControls.GetUserTimelineAsync(string userid, OAuthToken TwitterAccessToken, string ConsumerKey, string ConsumerSecret);
See response format
- Search
string response = await TwitterControls.SearchTweetsAsync(string SearchQuery);
See response format
###Release Notes:
Author: Sagar Mohite
Release Date: 12 August 2012
MinTwit Version 1.0.0
License: Apache License, Version 2.0