3

I've been stuck for a while on the following problem when I debug the following code:

        TwitterService service = new TwitterService("_consumerkey", "_consumersecret");

        OAuthRequestToken requestToken = service.GetRequestToken();

        Uri uri = service.GetAuthorizationUri(requestToken);
        Process.Start(uri.ToString());

        Console.Write("Verificatiecode? ");
        string verifier = Console.ReadLine();
        OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

        service.AuthenticateWith(access.Token, access.TokenSecret);

        TwitterUser twitterUser = service.GetUserProfile(new GetUserProfileOptions());

        ListFriendsOptions friends_options = new ListFriendsOptions();
        friends_options.UserId = twitterUser.Id;
        friends_options.Cursor = -1;

        var friends = service.ListFriends(friends_options);

        do
        {
            if (friends_options.Cursor != null)
            {
                foreach (var friend in friends) {Console.WriteLine(friend.ScreenName);}
                friends_options.Cursor = friends.NextCursor;
            }

        } while (friends_options.Cursor != null);

        Console.ReadKey(true);

I always get an overflow exception after filling in the verification code here:

        OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

Anyone who can help me?

Thanks in advance

  • Any further progress on this, I have similar code working in my app but only some of the time it fails - other time it's fine. – James Mundy Nov 9 '13 at 23:43
3

Looking at the source, it seems like the problem is when it tries to return the results inside GetAccessToken:

 return new OAuthAccessToken()
  {
    Token = nameValueCollection["oauth_token"] ?? "?",
    TokenSecret = nameValueCollection["oauth_token_secret"] ?? "?",
    //this is the only place a conversion to int is occurring that I've found
    UserId = Convert.ToInt32(nameValueCollection["user_id"] ?? "0"),
    ScreenName = nameValueCollection["screen_name"] ?? "?"
  };

Looking on Github, it seems this update might solve the problem.

  • I am getting the same error, as I get latest TweetSharp library from Nuget – Khawaja Asim Mar 7 '17 at 18:59
2

Download the last version of TweetSharp, old version has user_id as Int32, but new version as Int64 https://github.com/danielcrenna/tweetsharp

1

This happens because Twitter introduced 64bit user ids a while back.

Older Twitter accounts still have the 32-bit Ids and TweetSharp works just fine with them. But if you opened an account recently you already might have a 64 bit ID and Tweet Sharp fails.

I fixed the problem by getting the tweetsharp-unofficial package from NuGet.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.