Created
July 30, 2012 05:17
-
-
Save lmt-swallow/3204987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InitializeTwitterConnection() | |
{ | |
string accessToken = Properties.Settings.Default.accessToken; | |
string accessTokenSecret = Properties.Settings.Default.accessTokenSecret; | |
if (accessToken == "" || accessTokenSecret == "") | |
{ | |
OAuthTokenResponse req = | |
OAuthUtility.GetRequestToken(Twitter.Secret.consumer_key, Twitter.Secret.consumer_key_secret, "oob"); | |
System.Diagnostics.Process.Start(OAuthUtility.BuildAuthorizationUri(req.Token).ToString()); | |
string pincode = Microsoft.VisualBasic.Interaction.InputBox("PIN CODE"); | |
OAuthTokenResponse actToken = | |
OAuthUtility.GetAccessToken(Twitter.Secret.consumer_key, Twitter.Secret.consumer_key_secret, req.Token, pincode); | |
accessToken = actToken.Token; | |
accessTokenSecret = actToken.TokenSecret; | |
} | |
OAuthTokens token = new OAuthTokens | |
{ | |
ConsumerKey = Twitter.Secret.consumer_key, | |
ConsumerSecret = Twitter.Secret.consumer_key_secret, | |
AccessToken = accessToken, | |
AccessTokenSecret = accessTokenSecret | |
}; | |
stream = new TwitterStream(token, "AsaTsubame", null); | |
stream.StartUserStream( | |
null,//friendTimeline | |
null,//userstreamStopped | |
(x) => { this.onGetTweet(x); }, //StatusCreated | |
null, //StatusDeleted | |
null, //DirectMessage | |
null, //DeleteDirectMessage | |
(x) => { this.onGetEvent(x); }, //Event | |
null); | |
Properties.Settings.Default.accessToken = accessToken; | |
Properties.Settings.Default.accessTokenSecret = accessTokenSecret; | |
Properties.Settings.Default.Save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment