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


C# TwitterService.GetAccessTokenWithXAuth方法代码示例

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


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

示例1: Authorize

        //
        // GET: /Twitter/
        public ActionResult Authorize()
        {
            // OAuth Access Token Exchange
            TwitterService service = new TwitterService("consumerKey", "consumerSecret");
            OAuthAccessToken access = service.GetAccessTokenWithXAuth("username", "password"); //

            return View();
        }
开发者ID:abordt,项目名称:Viking,代码行数:10,代码来源:TwitterController.cs

示例2: Authenticate

        public Account Authenticate(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("userName");
            }

            TwitterService service = new TwitterService(ConfigurationManager.AppSettings["ConsumerKey"],
                ConfigurationManager.AppSettings["ConsumerSecret"]);

            OAuthAccessToken access = service.GetAccessTokenWithXAuth(userName, password);

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

            var profile = service.GetUserProfile();

            Account account = AccountManager.Instance.GetCurrentAccounts().Where(acc => acc.Username == profile.ScreenName).FirstOrDefault();
            if (account != null)
            {
                throw new AuthFailureException("User " + account.Username + " already has an account with TweetOBox.");
            }
            if (profile != null && account == null)
            {
                account = new Account();
                account.Username = profile.ScreenName;
                // account.Password = profile.p
                account.AccountType = (int)AccountTypeEnum.Twitter;
                account.AccessToken = access.Token;
                account.AccessTokenSecret = access.TokenSecret;
                account.IsOAuth = true;
                AccountManager.Instance.AddAccount(account, false);
            }
            else
            {
                throw new AuthFailureException(service.Response.StatusDescription);
            }

            return account;
        }
开发者ID:ankitb,项目名称:TweetOBox,代码行数:39,代码来源:NormalAuth.cs

示例3: getTweets

        /// <summary>
        /// uses the tweetsharp api to get all tweets for the given company
        /// </summary>
        /// <param name="companyname">the name of the company</param>
        /// <returns>all tweets formated for the input string for the sentiment analysis</returns>
        private string getTweets(string companyname)
        {
            Console.WriteLine("Getting the tweets...");
            TwitterService twitterService = new TwitterService("H70mkcnY9uKDDGUcKywlBA", "fiobr6kG9OKwNHIU5D18dbpxWE5KdxWD8GRPRhMVII");
            OAuthAccessToken access = twitterService.GetAccessTokenWithXAuth("2012AIC", "!aicgroup");

            ArrayList pages = new ArrayList();
            JsonSerializer serializer = new JsonSerializer();

            // you can changes this number to get more tweets (100 tweets per page)
            int numPages = 1;

            // get the tweets from the first x numpages
            for (int i = 1; i <= numPages; i++)
            {
                TwitterSearchResult response = twitterService.Search(companyname, i, 100);
                RootObject page = (RootObject)serializer.Deserialize(new JsonTextReader(new StringReader(response.RawSource)), typeof(RootObject));
                pages.Add(page);
            }

            string result = "{'data': [";

            int count = 0;
            int eng = 0;

            foreach (RootObject curPage in pages)
            {
                foreach (var tweet in curPage.results)
                {
                    count++;
                    if (tweet.iso_language_code.Equals("en"))
                    {
                        eng++;
                        string tweettext = tweet.text;
                        tweettext = replaceChars(tweettext);

                        result += "{'text': '" + tweettext + "', 'query': '" + companyname + "'}, ";
                    }
                }
            }

            Console.WriteLine(count + " tweets fetched, " + eng + " were english and saved for the sentiment analysis.\n");

            // get rid of the last comma
            result = result.Substring(0, result.Length - 2);
            result += "]}";
            return result;
        }
开发者ID:ERit,项目名称:aic_group2_topic1,代码行数:53,代码来源:StatisticService.svc.cs

示例4: TestWithTweetSharpXAuth

		private static void TestWithTweetSharpXAuth()
		{
			// OAuth Access Token Exchange
			TwitterService twitterService = new TwitterService(OAuthProperties.ConsumerKey, OAuthProperties.ConsumerKeySecret);
			twitterService.AuthenticateWith(OAuthProperties.AccessToken, OAuthProperties.AccessTokenSecret);

			Console.WriteLine("Enter Username...");
			string username = Console.ReadLine();
			Console.WriteLine("Enter Password...");
			string password = Console.ReadLine();
			OAuthAccessToken accessToken = twitterService.GetAccessTokenWithXAuth(username, password);

			twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
			var verifyCredentialsOptions = new VerifyCredentialsOptions { IncludeEntities = true };
			TwitterUser user = twitterService.VerifyCredentials(verifyCredentialsOptions);
		}
开发者ID:dance2die,项目名称:Project.TranslateTwitter,代码行数:16,代码来源:Program.cs


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