當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。