3

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.

casperOne
  • 73,706
  • 19
  • 184
  • 253
hjeldin
  • 53
  • 7

2 Answers2

1

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.

Evan Phillips
  • 261
  • 2
  • 4
1

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 ;)

Tjassens
  • 922
  • 6
  • 9
  • yes, i've already tried that way, both callback url are set in the application control panel from twitter and in the OAuth request. – hjeldin Nov 07 '11 at 20:06
  • can you show us the complete code for authenticating with twitter. I have done the same in a SharePoint webpart so maybe I can see the error in your code... – Tjassens Nov 07 '11 at 21:17
  • Ok, i managed to get it working. The problem was that i was refreshing the page called by the second controller, and the oauth_verifier was not valid anymore. Thanks everyone for the help! – hjeldin Nov 08 '11 at 15:05
  • This answer is correct, but a little misleading. Yes, it's a real bug and it's been fixed in the code repository, but setting a callback isn't really a _workaround_ as much as it is the cause of the underlying problem. The bug here is a secondary issue that's caused because of your application being registered incorrectly. – Ricky Smith Nov 08 '11 at 22:19
  • you're partially right. The issue wasnt the callback, it was the fact that his variables werent correct anymore after postback. Thats why I asked hjeldin to check the contents of his variables. – Tjassens Nov 09 '11 at 07:06