コード例 #1
0
ファイル: ShareTwitter.xaml.cs プロジェクト: supudo/Neolog-WP
        void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                var parameters = TwitterHelper.GetQueryParameters((new StreamReader(e.Response)).ReadToEnd());
                accessToken = parameters["oauth_token"];
                accessTokenSecret = parameters["oauth_token_secret"];
                userID = parameters["user_id"];
                userScreenName = parameters["screen_name"];

                TwitterHelper.SetKeyValue<string>("AccessToken", accessToken);
                TwitterHelper.SetKeyValue<string>("AccessTokenSecret", accessTokenSecret);
                TwitterHelper.SetKeyValue<string>("ScreenName", userScreenName);

                Dispatcher.BeginInvoke(() =>
                {
                    var SignInMenuItem = (Microsoft.Phone.Shell.ApplicationBarMenuItem)this.ApplicationBar.MenuItems[0];
                    SignInMenuItem.IsEnabled = false;

                    var SignOutMenuItem = (Microsoft.Phone.Shell.ApplicationBarMenuItem)this.ApplicationBar.MenuItems[1];
                    SignOutMenuItem.IsEnabled = true;

                    var tweetButton = (Microsoft.Phone.Shell.ApplicationBarIconButton)this.ApplicationBar.Buttons[0];
                    tweetButton.IsEnabled = true;
                });
                this.postMessageToTwitter();
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: mmydland/burntracker
        void requestTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            OAuthWebQuery query = sender as OAuthWebQuery;
            if (query.Result.ResponseHttpStatusDescription == "OK")
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(e.Response);
                var parameters = HelperMethods.GetQueryParameters(sr.ReadToEnd());
                OAuthTokenKey = parameters["oauth_token"];
                tokenSecret = parameters["oauth_token_secret"];
                var authorizeUrl = DailyBurnSettings.AuthorizeUri + "?oauth_token=" + OAuthTokenKey;

                Dispatcher.BeginInvoke(() =>
                {
                    this.authorizeWebBrowser.Navigate(new Uri(authorizeUrl));
                });
            }
            else
            {
                Dispatcher.BeginInvoke(() =>
                {
                    authorizeTextBlock.Text = dbwp7Resources.CannotConnectToDailyBurn;
                    authorizeTextBlock.Visibility = Visibility.Visible;
                    btnSignIn.IsEnabled = false;
                    btnSignIn.Visibility = Visibility.Collapsed;
                });
            }
            
        }
コード例 #3
0
        private WebQueryAsyncResult ExecuteGetOrDeleteAsync(ICache cache, 
                                                            string key, 
                                                            string url, 
                                                            WebRequest request,
                                                            object userState)
        {
            var fetch = cache.Get<Stream>(key);
            if (fetch != null)
            {
                var args = new WebQueryResponseEventArgs(fetch);
                OnQueryResponse(args);

                var result = new WebQueryAsyncResult
                {
                    CompletedSynchronously = true
                };
                return result;
            }
            else
            {
                var state = new Triplet<WebRequest, Pair<ICache, string>, object>
                                {
                                    First = request,
                                    Second = new Pair<ICache, string>
                                                 {
                                        First = cache,
                                        Second = key
                                    },
                                    Third = userState
                                };

                var args = new WebQueryRequestEventArgs(url);
                OnQueryRequest(args);

                var inner = request.BeginGetResponse(GetAsyncResponseCallback, state);
                RegisterAbortTimer(request, inner); 
                var result = new WebQueryAsyncResult { InnerResult = inner };
                return result;
            }
        }
コード例 #4
0
        public void RefreshTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                StreamReader reader = new StreamReader(e.Response);
                string strResponse = reader.ReadToEnd();
                var parameters = MainUtil.GetQueryParameters(strResponse);
                var accessToken = parameters["oauth_token"];
                var accessTokenSecret = parameters["oauth_token_secret"];
                TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));

                MainUtil.SetKeyValue<string>("AccessToken", accessToken);
                MainUtil.SetKeyValue<string>("AccessTokenSecret", accessTokenSecret);
                MainUtil.SetKeyValue<string>("Timestamp", t.TotalSeconds.ToString());
}
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
コード例 #5
0
ファイル: MainPage.xaml.cs プロジェクト: T4SG/Mumbai-Team-11
        void requestTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                StreamReader reader = new StreamReader(e.Response);
                string strResponse = reader.ReadToEnd();
                var parameters = MainUtil.GetQueryParameters(strResponse);
                OAuthTokenKey = parameters["oauth_token"];
                tokenSecret = parameters["oauth_token_secret"];
                var authorizeUrl = AppSettings.AuthorizeUri + "?oauth_token=" + OAuthTokenKey;

                Dispatcher.BeginInvoke(() =>
                {
                    this.loginBrowserControl.Navigate(new Uri(authorizeUrl, UriKind.RelativeOrAbsolute));
                });
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
コード例 #6
0
        void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                StreamReader reader = new StreamReader(e.Response);
                string strResponse = reader.ReadToEnd();
                var parameters = MainUtil.GetQueryParameters(strResponse);

                ObjCommon.Twittertoken = parameters["oauth_token"];
                ObjCommon.TwitterAccessTokenSecret = parameters["oauth_token_secret"];
                ObjCommon.TwitterScreenName = parameters["screen_name"];
                ObjCommon.SaveSettings();
                userLoggedIn();
                if (userID != "" && userScreenName != "")
                {
                    var service = new TwitterService(consumerKey, consumerKeySecret);
                    service.AuthenticateWith(accessToken.ToString(), accessTokenSecret);

                    service.ListTweetsOnHomeTimeline(new TweetSharp.ListTweetsOnHomeTimelineOptions() { Count = 20 }, (ts, rep) =>
                    {

                        if (rep.StatusCode == HttpStatusCode.OK)
                        {

                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
コード例 #7
0
        protected virtual void PostAsyncRequestCallback(IAsyncResult asyncResult)
        {
            WebRequest request;
            byte[] post;
            object userState;
            Triplet<ICache, object, string> store;

            var state = asyncResult.AsyncState as Triplet<WebRequest, byte[], object>;
            if (state == null)
            {
                // No expiration specified
                if (asyncResult is Triplet<WebRequest, Triplet<byte[], ICache, string>, object>)
                {
                    var cacheScheme = (Triplet<WebRequest, Triplet<byte[], ICache, string>, object>)asyncResult;
                    var cache = cacheScheme.Second.Second;

                    var url = cacheScheme.First.RequestUri.ToString();
                    var prefix = cacheScheme.Second.Third;
                    var key = CreateCacheKey(prefix, url);

                    var fetch = cache.Get<Stream>(key);
                    if (fetch != null)
                    {
                        var args = new WebQueryResponseEventArgs(fetch);
                        OnQueryResponse(args);
                        return;
                    }

                    request = cacheScheme.First;
                    post = cacheScheme.Second.First;
                    userState = cacheScheme.Third;
                    store = new Triplet<ICache, object, string>
                    {
                        First = cache,
                        Second = null,
                        Third = prefix
                    };
                }
                else
                    // Absolute expiration specified
                    if (asyncResult is Triplet<WebRequest, Pair<byte[], Triplet<ICache, DateTime, string>>, object>)
                    {
                        var cacheScheme = (Triplet<WebRequest, Pair<byte[], Triplet<ICache, DateTime, string>>, object>)asyncResult;
                        var url = cacheScheme.First.RequestUri.ToString();
                        var cache = cacheScheme.Second.Second.First;
                        var expiry = cacheScheme.Second.Second.Second;

                        var prefix = cacheScheme.Second.Second.Third;
                        var key = CreateCacheKey(prefix, url);

                        var fetch = cache.Get<Stream>(key);
                        if (fetch != null)
                        {
                            var args = new WebQueryResponseEventArgs(fetch);
                            OnQueryResponse(args);
                            return;
                        }

                        request = cacheScheme.First;
                        post = cacheScheme.Second.First;
                        userState = cacheScheme.Third;
                        store = new Triplet<ICache, object, string>
                        {
                            First = cache,
                            Second = expiry,
                            Third = prefix
                        };
                    }
                    else
                        // Sliding expiration specified
                        if (asyncResult is Triplet<WebRequest, Pair<byte[], Triplet<ICache, TimeSpan, string>>, object>)
                        {
                            var cacheScheme = (Triplet<WebRequest, Pair<byte[], Triplet<ICache, TimeSpan, string>>, object>)asyncResult;
                            var url = cacheScheme.First.RequestUri.ToString();
                            var cache = cacheScheme.Second.Second.First;
                            var expiry = cacheScheme.Second.Second.Second;

                            var prefix = cacheScheme.Second.Second.Third;
                            var key = CreateCacheKey(prefix, url);

                            var fetch = cache.Get<Stream>(key);
                            if (fetch != null)
                            {
                                var args = new WebQueryResponseEventArgs(fetch);
                                OnQueryResponse(args);
                                return;
                            }

                            request = cacheScheme.First;
                            post = cacheScheme.Second.First;
                            userState = cacheScheme.Third;
                            store = new Triplet<ICache, object, string>
                            {
                                First = cache,
                                Second = expiry,
                                Third = prefix
                            };
                        }
                        else
                        {
                            // Unrecognized state signature
                            throw new ArgumentNullException("asyncResult",
                                                            "The asynchronous post failed to return its state");
                        }
            }
            else
            {
                request = state.First;
                post = state.Second;
                userState = state.Third;
                store = null;
            }

            // No cached response
            using (var stream = request.EndGetRequestStream(asyncResult))
            {
                WritePostContentToRequestStream(post, stream);

                var inner = request.BeginGetResponse(PostAsyncResponseCallback,
                                         new Triplet<WebRequest, Triplet<ICache, object, string>, object>
                                         {
                                             First = request,
                                             Second = store,
                                             Third = userState
                                         });

                RegisterAbortTimer(request, new WebQueryAsyncResult { InnerResult = inner });
            }
        }
コード例 #8
0
 private void EndStreaming(WebRequest request)
 {
     _isStreaming = false;
     
     var stream = new MemoryStream(_endStreamBytes);
     var args = new WebQueryResponseEventArgs(stream);
     OnQueryResponse(args);
     request.Abort();
 }
コード例 #9
0
 private void WebQueryNewStreamMessageEvent(Stream message)
 {
     var args = new WebQueryResponseEventArgs(message);
     OnQueryResponse(args);
 }
コード例 #10
0
        protected virtual void GetAsyncResponseCallback(IAsyncResult asyncResult)
        {

#if WindowsPhone
            Interlocked.Increment(ref completed);
#endif

            Console.Out.WriteLine("----- WebQuery.Async.cs GetAsyncResponseCallback");

            object store;
            var request = GetAsyncCacheStore(asyncResult, out store);

            try
            {
                var response = request.EndGetResponse(asyncResult);
                using (response)
                {
#if SILVERLIGHT
                    if (DecompressionMethods == Silverlight.Compat.DecompressionMethods.GZip ||
                        DecompressionMethods == Silverlight.Compat.DecompressionMethods.Deflate ||
                        DecompressionMethods == (Silverlight.Compat.DecompressionMethods.GZip | Silverlight.Compat.DecompressionMethods.Deflate)
                        )
                    {
                        response = new GzipHttpWebResponse((HttpWebResponse)response);
                    }
#endif
                    WebResponse = response;
                    
                    ContentStream = response.GetResponseStream();
                    
                    if (store != null)
                    {
                        // No expiration specified
                        if (store is Pair<ICache, string>)
                        {
                            var cache = store as Pair<ICache, string>;
                            cache.First.Insert(cache.Second, ContentStream);
                        }

                        // Absolute expiration specified
                        if (store is Pair<ICache, Pair<string, DateTime>>)
                        {
                            var cache = store as Pair<ICache, Pair<string, DateTime>>;
                            cache.First.Insert(cache.Second.First, ContentStream, cache.Second.Second);
                        }

                        // Sliding expiration specified
                        if (store is Pair<ICache, Pair<string, TimeSpan>>)
                        {
                            var cache = store as Pair<ICache, Pair<string, TimeSpan>>;
                            cache.First.Insert(cache.Second.First, ContentStream, cache.Second.Second);
                        }
                    }

                    // Only send query when caching is complete
                    var args = new WebQueryResponseEventArgs(ContentStream);
                    OnQueryResponse(args);
                }
            }
            catch (WebException ex)
            {
                HandleWebException(ex);
            }
        }
コード例 #11
0
ファイル: MainPage.xaml.cs プロジェクト: mmydland/burntracker
        void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
          
            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(e.Response);
                var parameters = HelperMethods.GetQueryParameters(sr.ReadToEnd());
                accessToken = parameters["oauth_token"];
                accessTokenSecret = parameters["oauth_token_secret"];

                HelperMethods.SetKeyValue("accessToken", accessToken);
                HelperMethods.SetKeyValue("accessTokenSecret", accessTokenSecret);

                navigateToJumpPage();
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
コード例 #12
0
ファイル: ShareTwitter.xaml.cs プロジェクト: supudo/Neolog-WP
        void requestTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                var parameters = TwitterHelper.GetQueryParameters((new StreamReader(e.Response)).ReadToEnd());
                OAuthTokenKey = parameters["oauth_token"];
                tokenSecret = parameters["oauth_token_secret"];
                var authorizeUrl = AppSettings.TwitterAuthorizeUri + "?oauth_token=" + OAuthTokenKey;

                Dispatcher.BeginInvoke(() =>
                {
                    this.wbTwitter.Navigate(new Uri(authorizeUrl));
                });
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }
コード例 #13
0
ファイル: TwitterHelper.cs プロジェクト: FaisalNahian/311NYC
        static void objOAuthWebQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {

            var parameters = GetQueryParameters(e.Response);
            IsolatedStorageSettings.ApplicationSettings[TWITTER_REQ_TOKEN_KEY] = parameters["oauth_token"];
            IsolatedStorageSettings.ApplicationSettings[TWITTER_REQ_SECRET_KEY] = parameters["oauth_token_secret"];

            IsolatedStorageSettings.ApplicationSettings.Save();

            var authorizeUrl = TwitterSettings.AuthorizeUri + "?oauth_token=" + IsolatedStorageSettings.ApplicationSettings[TWITTER_REQ_TOKEN_KEY];

            
            DispatcherHelper.UIDispatcher.BeginInvoke(() =>
            {
                m_browser.Visibility = Visibility.Visible;
                m_browser.Navigating += new EventHandler<NavigatingEventArgs>(m_browser_Navigating);
                m_browser.Navigate(new Uri(authorizeUrl));
            });



        }
コード例 #14
0
ファイル: TwitterHelper.cs プロジェクト: FaisalNahian/311NYC
        static void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            
                var parameters =GetQueryParameters(e.Response);
                IsolatedStorageSettings.ApplicationSettings[TWITTER_ACCESS_TOKEN_KEY] = parameters["oauth_token"];
                IsolatedStorageSettings.ApplicationSettings[TWITTER_ACCESS_SECRET_KEY] = parameters["oauth_token_secret"];
                IsolatedStorageSettings.ApplicationSettings.Save();

                Messenger.Default.Send(TwitterMessages.TwitterLoginSuccess);
        }
コード例 #15
0
        protected virtual void PostAsyncRequestCallbackMultiPart(IAsyncResult asyncResult)
        {
            WebRequest request;
            string boundary;
            IEnumerable<HttpPostParameter> parameters;
            object userState;
            Triplet<ICache, object, string> store;

            var state = asyncResult.AsyncState as Triplet<WebRequest, Pair<string, IEnumerable<HttpPostParameter>>, object>;
            if (state == null)
            {
                // No expiration specified
                if (asyncResult is Triplet<WebRequest, Triplet<Pair<string, IEnumerable<HttpPostParameter>>, ICache, string>, object>)
                {
                    #region No Expiration
                    var cacheScheme = (Triplet<WebRequest, Triplet<Pair<string, IEnumerable<HttpPostParameter>>, ICache, string>, object>)asyncResult;
                    var cache = cacheScheme.Second.Second;

                    var url = cacheScheme.First.RequestUri.ToString();
                    var prefix = cacheScheme.Second.Third;
                    var key = CreateCacheKey(prefix, url);

                    var fetch = cache.Get<Stream>(key);
                    if (fetch != null)
                    {
                        var args = new WebQueryResponseEventArgs(fetch);
                        OnQueryResponse(args);
                        return;
                    }

                    request = cacheScheme.First;
                    boundary = cacheScheme.Second.First.First;
                    parameters = cacheScheme.Second.First.Second;
                    userState = cacheScheme.Third;
                    store = new Triplet<ICache, object, string>
                                {
                                    First = cache,
                                    Second = null,
                                    Third = prefix
                                };
                    #endregion
                }
                else
                    // Absolute expiration specified
                    if (asyncResult is Triplet<WebRequest, Pair<Pair<string, IEnumerable<HttpPostParameter>>, Triplet<ICache, DateTime, string>>, object>)
                    {
                        #region Absolute Expiration
                        var cacheScheme = (Triplet<WebRequest, Pair<Pair<string, IEnumerable<HttpPostParameter>>, Triplet<ICache, DateTime, string>>, object>)asyncResult;
                        var url = cacheScheme.First.RequestUri.ToString();
                        var cache = cacheScheme.Second.Second.First;
                        var expiry = cacheScheme.Second.Second.Second;

                        var prefix = cacheScheme.Second.Second.Third;
                        var key = CreateCacheKey(prefix, url);

                        var fetch = cache.Get<Stream>(key);
                        if (fetch != null)
                        {
                            var args = new WebQueryResponseEventArgs(fetch);
                            OnQueryResponse(args);
                            return;
                        }

                        request = cacheScheme.First;
                        boundary = cacheScheme.Second.First.First;
                        parameters = cacheScheme.Second.First.Second;
                        userState = cacheScheme.Third;
                        store = new Triplet<ICache, object, string>
                                    {
                                        First = cache,
                                        Second = expiry,
                                        Third = prefix
                                    };
                        #endregion
                    }
                    else
                        // Sliding expiration specified
                        if (asyncResult is Triplet<WebRequest, Pair<Pair<string, IEnumerable<HttpPostParameter>>, Triplet<ICache, TimeSpan, string>>, object>)
                        {
                            #region Sliding Expiration
                            var cacheScheme = (Triplet<WebRequest, Pair<Pair<string, IEnumerable<HttpPostParameter>>, Triplet<ICache, TimeSpan, string>>, object>)asyncResult;
                            var url = cacheScheme.First.RequestUri.ToString();
                            var cache = cacheScheme.Second.Second.First;
                            var expiry = cacheScheme.Second.Second.Second;

                            var prefix = cacheScheme.Second.Second.Third;
                            var key = CreateCacheKey(prefix, url);

                            var fetch = cache.Get<Stream>(key);
                            if (fetch != null)
                            {
                                var args = new WebQueryResponseEventArgs(fetch);
                                OnQueryResponse(args);
                                return;
                            }

                            request = cacheScheme.First;
                            boundary = cacheScheme.Second.First.First;
                            parameters = cacheScheme.Second.First.Second;
                            userState = cacheScheme.Third;
                            store = new Triplet<ICache, object, string>
                                        {
                                            First = cache,
                                            Second = expiry,
                                            Third = prefix
                                        };
                            #endregion
                        }
                        else
                        {
                            // Unrecognized state signature
                            throw new ArgumentNullException("asyncResult",
                                                            "The asynchronous post failed to return its state");
                        }
            }
            else
            {
                request = state.First;
                boundary = state.Second.First;
                parameters = state.Second.Second;
                userState = state.Third;
                store = null;
            }

#if !Smartphone
            var encoding = Encoding ?? Encoding.GetEncoding("ISO-8859-1");
#else
            var encoding = Encoding ?? Encoding.GetEncoding(1252);
#endif
            var expected = WriteMultiPartImpl(
                false /* write */, parameters, boundary, encoding, null
                );
            
            // No cached response
            using (var requestStream = request.EndGetRequestStream(asyncResult))
            {
                var actual = WriteMultiPartImpl(
                        true /* write */, parameters, boundary, encoding, requestStream
                        );

                Debug.Assert(expected == actual, string.Format("Expected {0} bytes but wrote {1}!", expected, actual));

                var inner = request.BeginGetResponse(PostAsyncResponseCallback,
                                         new Triplet<WebRequest, Triplet<ICache, object, string>, object>
                                             {
                                                 First = request,
                                                 Second = store,
                                                 Third = userState
                                             });

                RegisterAbortTimer(request, new WebQueryAsyncResult { InnerResult = inner });
            }
        }
コード例 #16
0
        protected virtual void PostAsyncResponseCallback(IAsyncResult asyncResult)
        {
#if WindowsPhone
            Interlocked.Increment(ref completed);
#endif

            WebRequest request;
            Triplet<WebRequest, Triplet<ICache, object, string>, object> state;
            try
            {
                state = asyncResult.AsyncState as Triplet<WebRequest, Triplet<ICache, object, string>, object>;
                if (state == null)
                {
                    throw new ArgumentNullException("asyncResult", "The asynchronous post failed to return its state");
                }

                request = state.First;
                if (request == null)
                {
                    throw new ArgumentNullException("asyncResult", "The asynchronous post failed to return a request");
                }
            }
            catch(Exception ex)
            {
                var args = new WebQueryResponseEventArgs(new MemoryStream(), ex);
                OnQueryResponse(args);
                return;
            }

            try
            {
                // Avoid disposing until no longer needed to build results
                var response = request.EndGetResponse(asyncResult);

#if SILVERLIGHT
                if (DecompressionMethods == Silverlight.Compat.DecompressionMethods.GZip ||
                    DecompressionMethods == Silverlight.Compat.DecompressionMethods.Deflate ||
                    DecompressionMethods == (Silverlight.Compat.DecompressionMethods.GZip | Silverlight.Compat.DecompressionMethods.Deflate)
                    )
                {
                    response = new GzipHttpWebResponse((HttpWebResponse)response);
                }
#endif
                WebResponse = response;

                ContentStream = response.GetResponseStream();
                if (state.Second != null)
                {
                    var cache = state.Second.First;
                    var expiry = state.Second.Second;
                    var url = request.RequestUri.ToString();

                    var prefix = state.Second.Third;
                    var key = CreateCacheKey(prefix, url);

                    if (expiry is DateTime)
                    {
                        // absolute
                        cache.Insert(key, ContentStream, (DateTime)expiry);
                    }

                    if (expiry is TimeSpan)
                    {
                        // sliding
                        cache.Insert(key, ContentStream, (TimeSpan)expiry);
                    }
                }

                var args = new WebQueryResponseEventArgs(ContentStream);
                OnQueryResponse(args);
            }
            catch (WebException ex)
            {
                HandleWebException(ex);
            }
        }
コード例 #17
0
ファイル: MainPage.xaml.cs プロジェクト: T4SG/Mumbai-Team-11
        void AccessTokenQuery_QueryResponse(object sender, WebQueryResponseEventArgs e)
        {
            try
            {
                StreamReader reader = new StreamReader(e.Response);
                string strResponse = reader.ReadToEnd();
                var parameters = MainUtil.GetQueryParameters(strResponse);
                accessToken = parameters["oauth_token"];
                accessTokenSecret = parameters["oauth_token_secret"];
                userID = parameters["user_id"];
                userScreenName = parameters["screen_name"];

                MainUtil.SetKeyValue<string>("AccessToken", accessToken);
                MainUtil.SetKeyValue<string>("AccessTokenSecret", accessTokenSecret);
                MainUtil.SetKeyValue<string>("ScreenName", userScreenName);

                userLoggedIn();


            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
        }