예제 #1
0
 public Account()
 {
     OAuth = new OAuth();
     Twitter = new Twitter();
     Templates = new List<Template>();
 }
예제 #2
0
        public Account SignIn(string token, string verifier)
        {
            var requestToken = new OAuthRequestToken { Token = token };
            var twitter = new TwitterService(TwitterConsumerKey, TwitterConsumerSecret);
            ChangeApiAccessHttpsToHttp(twitter);

            var accessToken = twitter.GetAccessToken(requestToken, verifier);
            twitter.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            var user = twitter.VerifyCredentials();
            if (string.IsNullOrWhiteSpace(user.ScreenName))
                return null;

            // 保持しておくのはRequestTokenじゃなくてAccessTokenなんだぜ!
            // 一日潰れたぜ!
            var oauth = new OAuth
            {
                Token = accessToken.Token,
                TokenSecret = accessToken.TokenSecret,
                Verifier = verifier,
            };

            var twitterAccount = new Twitter
            {
                Name = user.Name,
                ScreenName = user.ScreenName,
                ProfileImageUrl = user.ProfileImageUrl
            };

            return UpdateAccount(oauth, twitterAccount);
        }