gpt4 book ai didi

c# - Tweetsharp - Oauthaccestoken 溢出异常

转载 作者:太空狗 更新时间:2023-10-30 00:52:48 27 4
gpt4 key购买 nike

当我调试下面的代码时,我在下面的问题上卡住了一段时间:

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

总是在这里填写验证码后溢出异常:

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

谁能帮帮我?

提前致谢

最佳答案

查看源代码,问题似乎出在它试图在 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"] ?? "?"
};

在Github上看好像是this update可能会解决问题。

关于c# - Tweetsharp - Oauthaccestoken 溢出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19829649/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com