当前位置: 首页>>代码示例>>C#>>正文


C# TwitterService.VerifyCredentials方法代码示例

本文整理汇总了C#中TweetSharp.TwitterService.VerifyCredentials方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.VerifyCredentials方法的具体用法?C# TwitterService.VerifyCredentials怎么用?C# TwitterService.VerifyCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TweetSharp.TwitterService的用法示例。


在下文中一共展示了TwitterService.VerifyCredentials方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessAuthoriztion

        public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
        {
            var twitterService = new TwitterService(KeyStorage.Get("twitterKey"), KeyStorage.Get("twitterSecret"));

            if (String.IsNullOrEmpty(context.Request["oauth_token"]) ||
                String.IsNullOrEmpty(context.Request["oauth_verifier"]))
            {
                var requestToken = twitterService.GetRequestToken(context.Request.Url.AbsoluteUri);

                var uri = twitterService.GetAuthorizationUri(requestToken);

                context.Response.Redirect(uri.ToString(), true);
            }
            else
            {
                var requestToken = new OAuthRequestToken { Token = context.Request["oauth_token"] };
                var accessToken = twitterService.GetAccessToken(requestToken, context.Request["oauth_verifier"]);
                twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                var user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

                return ProfileFromTwitter(user);
            }

            return new LoginProfile();

        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:27,代码来源:TwitterLoginProvider.cs

示例2: bw_DoWork

        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            TwitterService service = new TwitterService(consumerKeyTextBox.Text, consumerSecretTextBox.Text, accessTokenTextBox.Text, accessTokenSecretTextBox.Text);

            TwitterUser user = service.VerifyCredentials();

            if (service.Response.InnerException != null)
            {
                TwitterError error = service.Deserialize<TwitterError>(service.Response.Response);
                if (!string.IsNullOrEmpty(error.ErrorMessage))
                {
                    e.Result = error; // return the error object on failure
                }
                else
                {
                    e.Result = null; // err, dunno. return null
                }
            }
            else if (user != null)
            {
                e.Result = user; // return user object on success
            }
            else
            {
                e.Result = null; // unknown error
            }
        }
开发者ID:SpikedCola,项目名称:twitply,代码行数:27,代码来源:Settings.cs

示例3: getTwitterFollowerList

        public List<TwitterFollower> getTwitterFollowerList()
        {
            List<TwitterFollower> twitterFollowerList = new List<TwitterFollower>();

            string _consumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerKeyLogin"];
            string _consumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumerSecretLogin"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            if (!string.IsNullOrEmpty(Session[Sessionvars.TwitterRequestToken].ToString()))
            {

                service.AuthenticateWith(Session[Sessionvars.TwitterRequestToken].ToString(), Session[Sessionvars.TwitterRequestTokenSecert].ToString());

                TwitterUser user = service.VerifyCredentials();
                var followers = service.ListFollowers();

                foreach (var follower in followers)
                {
                    twitterFollowerList.Add(
                   new TwitterFollower
                   {
                       Id = follower.Id,
                       ScreenName = follower.ScreenName
                   });
                }

            }

            return twitterFollowerList;
        }
开发者ID:emiprotech,项目名称:loginwithtwitter,代码行数:30,代码来源:HomeController.cs

示例4: GetUser

 public TwitterUser GetUser(LoginModel model)
 {
     var twitterService = new TweetSharp.TwitterService(ConsumerKey, ConsumerSecret);
     twitterService.AuthenticateWith(model.Token, model.Secret);
     TwitterUser user = twitterService.VerifyCredentials(new VerifyCredentialsOptions() { IncludeEntities = false, SkipStatus = false });
     return user;
 }
开发者ID:hafnis,项目名称:Sociopath,代码行数:7,代码来源:TwitterService.cs

示例5: GetLoginProfile

        public LoginProfile GetLoginProfile(string accessToken)
        {
            var twitterService = new TwitterService(KeyStorage.Get("twitterKey"), KeyStorage.Get("twitterSecret"));

            //??? tokenSecret
            twitterService.AuthenticateWith(accessToken, null);

            var user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

            return ProfileFromTwitter(user);
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:11,代码来源:TwitterLoginProvider.cs

示例6: LoginCallback

        public ActionResult LoginCallback(string returnUrl, string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken {Token = oauth_token};
            var service = new TwitterService(ConsumerKey, ConsumerSecret);
            var accessToken = service.GetAccessToken(requestToken, oauth_verifier);
            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            var twitterUser = service.VerifyCredentials(new VerifyCredentialsOptions());

            var user = new User {Name = twitterUser.ScreenName, DisplayName = twitterUser.Name, ImageUrl = new Uri(twitterUser.ProfileImageUrl)};
            userRepository.Save(user);
            FormsAuthentication.SetAuthCookie(user.Name, false);
            return Redirect(returnUrl);
        }
开发者ID:RomanGorgol,项目名称:nosql,代码行数:13,代码来源:AuthController.cs

示例7: AuthorizeCallback

        // Registered @ http://dev.twitter.com
        public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauth_token };

            // Exchange the Request Token for an Access Token
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            // User Authenticates using the Access Token
            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = service.VerifyCredentials(new VerifyCredentialsOptions());
            ViewBag.TwitMessage = "Connected";
            return View();
        }
开发者ID:okeltw,项目名称:OSUHackathon15,代码行数:15,代码来源:HomeController.cs

示例8: AuthorizeCallback

        public ActionResult AuthorizeCallback(string oauthToken, string oauthVerifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauthToken };

            // Step 3: Exchange the request token for an access token
            TwitterService svc = new TwitterService(_key, _secret);
            OAuthAccessToken accessToken = svc.GetAccessToken(requestToken, oauthVerifier);

            // Step 4: User authentication using the Access Token
            svc.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = svc.VerifyCredentials();
            ViewModel.Message = string.Format("Your username is {0}", user.ScreenName);
            return View();
        }
开发者ID:nageshverma2003,项目名称:TrackProtectSource,代码行数:14,代码来源:TpTwitter.cs

示例9: GetAllTweets

        /// <summary>
        /// Gets all the users tweets.
        /// </summary>
        /// <returns></returns>
        public IList<Tweet> GetAllTweets()
        {
            List<Tweet> tweets = new List<Tweet>();

            TwitterService twitterService = new TwitterService(AuthenticationTokens.TwitterConsumerKey, AuthenticationTokens.TwitterConsumerSecret);
            twitterService.AuthenticateWith(AuthenticationTokens.TwitterConsumerKey, AuthenticationTokens.TwitterConsumerSecret,
                                      _authentication.AccessToken, _authentication.AccessTokenSecret);

            TwitterUser twitterUser = twitterService.VerifyCredentials();

            //ListTweetsOnHomeTimeline only returns 200 (or 800?) results each go. Need to send the requests a few times per hour
            //with the paging/counts set?
            IEnumerable<TwitterStatus> returnedTweets = null;

            //try it a few times
            int retryCount = 0;
            while (returnedTweets == null)
            {
                returnedTweets = twitterService.ListTweetsOnHomeTimeline(200);

                retryCount++;

                //give up after 5 retries
                if (retryCount == 5)
                    return tweets;
            }

            foreach (var returnedTweet in returnedTweets)
            {
                Tweet tweet = new Tweet();

                TwitterStatus statusToExamine = returnedTweet;

                if (returnedTweet.RetweetedStatus != null)
                {
                    statusToExamine = returnedTweet.RetweetedStatus;

                }

                tweet.Author = new Linker() { Id = statusToExamine.Author.ScreenName, Name = statusToExamine.Author.ScreenName };
                tweet.Content = statusToExamine.Text;
                tweet.DatePosted = statusToExamine.CreatedDate;
                tweet.TweetId = statusToExamine.Id;
                tweet.ReTweetCount = GetRetweetCountFromRawData(statusToExamine.RawSource);

                tweets.Add(tweet);
            }
            return tweets;
        }
开发者ID:RodH257,项目名称:RetrEave,代码行数:53,代码来源:TwitterStreamRetriever.cs

示例10: AuthorizeCallback

        // This URL is registered as the application's callback at http://dev.twitter.com
        public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauth_token };

            // Step 3 - Exchange the Request Token for an Access Token
            TwitterService service = new TwitterService(TwitterSettings.ConsumerKey, TwitterSettings.ConsumerSecret);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = service.VerifyCredentials(new VerifyCredentialsOptions());
            ViewBag.Title = string.Format("Your username is {0}", user.ScreenName);

            return View();
        }
开发者ID:dimitardanailov,项目名称:TwitterBackupBackendAndAngularjs,代码行数:16,代码来源:HomeController.cs

示例11: Execute

        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull((object) context, "context");
            if (context.Items.Length != 1)
                return;
            Item item = context.Items[0];

            var scService = new SitecoreService(item.Database);
            var settings = scService.GetItem<TwitterSettings>(SettingsPath);

            TwitterService twitterService = new TwitterService(settings.ConsumerKey, settings.ConsumerSecret);
            twitterService.AuthenticateWith(settings.AccessToken, settings.AccessTokenSecret);

            TwitterUser user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

            var tweet = scService.CreateType<SendTweetOptions>(item);
            twitterService.SendTweet(tweet);
        }
开发者ID:simonproctor,项目名称:VirtualSummit,代码行数:18,代码来源:TweetCommand.cs

示例12: Login

        public UserModel Login(string oauthToken, string oauthVerifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauthToken };

            // Step 3 - Exchange the Request Token for an Access Token
            var service = new TwitterService(ConfigurationManager.AppSettings["twitterConsumerKey"], ConfigurationManager.AppSettings["twitterConsumerSecret"]);
            var accessToken = service.GetAccessToken(requestToken, oauthVerifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = service.VerifyCredentials(new VerifyCredentialsOptions());
            return new UserModel
                   {
                       Login = user.ScreenName,
                       Name = user.Name,
                       SocialInstance = user
                   };
        }
开发者ID:pdrm6000,项目名称:RepoTest,代码行数:18,代码来源:TwitterAuthenticationService.cs

示例13: AuthorizeCallback

        // This URL is registered as the application's callback at http://dev.twitter.com
        public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauth_token };

            // Step 3 - Exchange the Request Token for an Access Token
            TwitterService service = new TwitterService(AuthenticationTokens.TwitterConsumerKey, AuthenticationTokens.TwitterConsumerSecret);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            //Store the access token and secret and create a new user account
            TwitterAuthentication authentication = new TwitterAuthentication()
                                                    {
                                                        AccessToken = accessToken.Token,
                                                        AccessTokenSecret = accessToken.TokenSecret
                                                    };

            //Authenticate account with twitter
            service.AuthenticateWith(AuthenticationTokens.TwitterConsumerKey,
                                        AuthenticationTokens.TwitterConsumerSecret,
                                        authentication.AccessToken, authentication.AccessTokenSecret);

            TwitterUser twitterUser = service.VerifyCredentials();

            ServiceLayer.UserDetailsService.AuthenticateTwitterAccount(authentication, twitterUser.ScreenName,
                                                                       twitterUser.Id);

            //store the credentials in forms auth?
            var authTicket = new FormsAuthenticationTicket(1, twitterUser.ScreenName, DateTime.Now,
                                                 DateTime.Now.AddMonths(6), true, "");

            string cookieContents = FormsAuthentication.Encrypt(authTicket);
            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookieContents)
            {
                Expires = authTicket.Expiration,
                Path = FormsAuthentication.FormsCookiePath
            };

            if (HttpContext != null)
            {
                HttpContext.Response.Cookies.Add(cookie);
            }

            //new {authentication.AccessToken, authentication.AccessTokenSecret, twitterUser.ScreenName}
            return RedirectToAction("UserProfile");
        }
开发者ID:RodH257,项目名称:RetrEave,代码行数:45,代码来源:AccountController.cs

示例14: Index

        //
        // GET: /Home/
        public ActionResult Index()
        {
            var token = Session["Twitter.AccessToken"];
            var tokenSecret = Session["Twitter.AccessTokenSecret"];

            if (token == null || tokenSecret == null)
                return RedirectToAction("Authorize", "Auth");

            TwitterService service = new TwitterService(ConfigurationManager.AppSettings["TwitterConsumerKey"], ConfigurationManager.AppSettings["TwitterConsumerSecret"]);
            service.AuthenticateWith(token.ToString(), tokenSecret.ToString());

            // TODO: Check that authentication succeeded

            TwitterUser user = service.VerifyCredentials(new VerifyCredentialsOptions());
            ViewBag.TwitterUsername = user.ScreenName;

            IEnumerable<TwitterStatus> favorites = service.ListFavoriteTweets(new ListFavoriteTweetsOptions { UserId = user.Id, Count = 20, IncludeEntities = true });
            ViewBag.Favorites = favorites;

            return View();
        }
开发者ID:ryanmcdonnell,项目名称:twinklelinks,代码行数:23,代码来源:HomeController.cs

示例15: GetAuthenticatedService

        private TwitterService GetAuthenticatedService()
        {
            try
            {
                var service = new TwitterService(TwitterAuthentication.Key, TwitterAuthentication.Secret);

                var accessToken = Session["AccessToken"] as OAuthAccessToken;

                if (accessToken == null)
                    return null;

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

                var twitterUser = service.VerifyCredentials();

                return twitterUser == null ? null : service;
            }
            catch
            {
                return null;
            }
        }
开发者ID:timothyclifford,项目名称:Hackathon,代码行数:22,代码来源:TwitterController.cs


注:本文中的TweetSharp.TwitterService.VerifyCredentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。