Exemple #1
0
        public void CompleteLogin(Action <bool> callback)
        {
            OAuthWebQuery accessTokenQuery = this.GetAccessTokenQuery();
            EventHandler <WebQueryResponseEventArgs> eventHandler = (EventHandler <WebQueryResponseEventArgs>)((sender, e) =>
            {
                try
                {
                    Dictionary <string, string> queryParameters = TwitterFriendsImportProvider.GetQueryParameters(new StreamReader(e.Response).ReadToEnd());
                    this._userId            = queryParameters["user_id"];
                    this._accessToken       = queryParameters["oauth_token"];
                    this._accessTokenSecret = queryParameters["oauth_token_secret"];
                    this._twitterClient     = new TwitterClient("f5dowbYEtg4PfEOQZEdnHoHdT", "cCosLgG0c7IeJL7qElkR9tMCMWPjDdMPDHGMY2QlOoHCbza09b", new AccessToken(this._accessToken, this._accessTokenSecret));
                    callback(true);
                }
                catch (Exception)
                {
                    callback(false);
                }
            });

            accessTokenQuery.QueryResponse += eventHandler;
            string url = "https://api.twitter.com/oauth/access_token";

            // ISSUE: variable of the null type

            accessTokenQuery.RequestAsync(url, null);
        }
Exemple #2
0
        public void Login()
        {
            OAuthWebQuery requestTokenQuery = TwitterFriendsImportProvider.GetRequestTokenQuery();
            EventHandler <WebQueryResponseEventArgs> eventHandler = (async(sender, args) =>
            {
                try
                {
                    this._oauthToken = TwitterFriendsImportProvider.GetQueryParameters(new StreamReader(args.Response).ReadToEnd())["oauth_token"];
                    await Launcher.LaunchUriAsync(new Uri(string.Format("{0}?oauth_token={1}", "https://api.twitter.com/oauth/authorize", this._oauthToken)));
                }
                catch
                {
                }
            });

            requestTokenQuery.QueryResponse += eventHandler;
            requestTokenQuery.RequestAsync("https://api.twitter.com/oauth/request_token", null);
        }