/*static public void PostTweet(string message, RestCallback callback) * { * var credentials = new OAuthCredentials * { * Type = OAuthType.ProtectedResource, * SignatureMethod = OAuthSignatureMethod.HmacSha1, * ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, * ConsumerKey = AppObject.GameInfo.TwitterConsumerKey, * ConsumerSecret = AppObject.GameInfo.TwitterConsumerSecret, * Token = TwitterClient.AccessToken, * TokenSecret = TwitterClient.AccessTokenSecret, * Version = "1.0" * }; * * var restClient = new RestClient * { * Authority = "https://api.twitter.com", * HasElevatedPermissions = true * }; * * var restRequest = new RestRequest * { * Credentials = credentials, * Path = "/1.1/statuses/update.json", * Method = WebMethod.Post * }; * * restRequest.AddParameter("status", message); * restClient.BeginRequest(restRequest, callback); * } * */ /*static private void PostTweetRequestCallback(RestRequest request, RestResponse response, object obj) * { * Deployment.Current.Dispatcher.BeginInvoke(() => * { * if (response.StatusCode == HttpStatusCode.OK) * { * MessageBox.Show("TWEET_POSTED_SUCCESSFULLY"); * } * else if (response.StatusCode == HttpStatusCode.Forbidden) * { * MessageBox.Show("TWEET_POST_ERR_UPDATE_LIMIT"); * } * else * { * MessageBox.Show("WEET_POST_ERR_FAILED"); * } * * }); * //var requestTokenQuery = OAuthUtil.GetRequestTokenQuery(); * //requestTokenQuery.RequestAsync(AppSettings.RequestTokenUri, null); * //requestTokenQuery.QueryResponse += new EventHandler<WebQueryResponseEventArgs>(requestTokenQuery_QueryResponse); * } * */ static public void Logout() { KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyAcessToken, string.Empty); KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyAcessTokenSecret, string.Empty); KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyUserName, string.Empty); KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyUserID, string.Empty); }
void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e) { try { Deployment.Current.Dispatcher.BeginInvoke(() => { StreamReader reader = new StreamReader(e.Response); string strResponse = reader.ReadToEnd(); var parameters = KeyValuePairUtils.GetQueryParameters(strResponse); TwitterClient.AccessToken = parameters["oauth_token"]; TwitterClient.AccessTokenSecret = parameters["oauth_token_secret"]; TwitterClient.UserID = parameters["user_id"]; TwitterClient.UserScreenName = parameters["screen_name"]; KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyAcessToken, TwitterClient.AccessToken); KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyAcessTokenSecret, TwitterClient.AccessTokenSecret); KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyUserName, TwitterClient.UserScreenName); KeyValuePairUtils.SetKeyValue <string>(TwitterClient.KeyUserID, TwitterClient.UserID); success(parameters["oauth_token"], parameters["oauth_token_secret"]); }); } catch (Exception ex) { fail(); } }