The given key was not found in the dictionary

风流意气都作罢 提交于 2020-01-02 23:50:32

问题


I'm developing windows phone 8 application. In this, I have to integrate Twitter. So I have followed the below tutorial.

http://code.msdn.microsoft.com/wpapps/Latest-Twitter-integration-a42e8bb6

I've implemented successfully twitter in my application. I've tested this in Emulator and in device also. Everything was fine.

Suddenly in the device the application is unable to open the twitter log in page. I'm getting the error in the below method at line started with **.

 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);
                pi.IsVisible = false;
            });                
        }
    }

The given key was not present in the dictionary.

But in Emulator I'm successfully redirected to log in page if user is not logged in and posting the message.

I don't know what is the problem in the device. Please help me as soon as possible. I'm looking forward your responses.


回答1:


This issue occurs when the the device you are using for testing the app is without simcard, as it the device without the simcard cannot match the timings of the twitter api server and this mismatch causes the authentication error, as for the api the credentials are invalid due to heavy difference in the timings between api server and device, hence try checking it on a device that has a simcard inside.



来源:https://stackoverflow.com/questions/21235047/the-given-key-was-not-found-in-the-dictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!