简体   繁体   中英

Twitterizer - Exception while GetAccessToken()

my twitterizer version is 2.3.3.21964 (donwloaded from nuget).

I have these simple 2 lines on the first Controller action:

token = OAuthUtility.GetRequestToken("XXX", "YYY",
    "http://test.roadevents.it/account/twitter_token",null);
return Redirect("http://twitter.com/oauth/authorize?oauth_token=" + token.Token);

The second controller action (twitter_token) is this:

OAuthTokenResponse token = OAuthUtility.GetAccessToken("XXX", "YYY", 
    oauth_token, oauth_verifier);
ViewBag.twToken = token.Token;

Where oauth_token and oauth_verifier are valorized variables. My code break while getting access token with this exception:

System.ArgumentNullException: value can't be null

System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12633595 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +224

Twitterizer.TwitterizerException.ParseRateLimitHeaders(WebResponse response) in

C:\\Projects\\twitterizer-132\\Twitterizer2\\Exceptions\\TwitterizerException.cs:205

I've googled for this problem, and from what I understand it has been solved since version 2.1, but I still have it.

I'm 100% sure my application is set up as web-app.

I've never used Twitterizer, but do have experience with the Twitter API so I'll take a stab at it.

It looks like the specific exception you are getting is a bug in Twitterizer, as it is trying to parse a string that is null into a number, a no no. Now, what is likely to be the real cause of your issue is shown in the call stack. You can see that a method called "ParseRateLimitHeaders" is executing before the exception occurs. This would lead me to believe that the oauth token that you are connecting to Twitter with is currently being rate limited. Rate limiting in the Twitter API happens every time a token exceeds roughly 250 API calls in an hour (at least this was the case about half a year ago).

So my advice would be to make sure that the token that you are trying to use is either your own (you can easily get one for your app from the Twitter website) or at the very least is not being used by a bunch of other people as rate limiting can set in really quickly.

i read that this is a bug found before. I do not know if it was fixed during the latest release but the accepted workaround at that time was to put a correct callback url in your twitter application on the dev site of twitter.

I would advise debugging you application to check if all the variables are filled with the correct data. Maybe you find something else which could help us help you ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM