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


C# Twitterizer.OAuthTokens类代码示例

本文整理汇总了C#中Twitterizer.OAuthTokens的典型用法代码示例。如果您正苦于以下问题:C# OAuthTokens类的具体用法?C# OAuthTokens怎么用?C# OAuthTokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetStatus

        /// <summary>
        /// Gets the rate limiting status status for the authenticated user.
        /// </summary>
        /// <param name="tokens">The OAuth tokens.</param>
        /// <param name="options">The options.</param>
        /// <returns>
        /// A <see cref="TwitterRateLimitStatus"/> instance.
        /// </returns>
        public static TwitterResponse<TwitterRateLimitStatus> GetStatus(OAuthTokens tokens, OptionalProperties options)
        {
            Commands.RateLimitStatusCommand command = new Twitterizer.Commands.RateLimitStatusCommand(tokens, options);
            TwitterResponse<TwitterRateLimitStatus> result = Core.CommandPerformer.PerformAction(command);

            return result;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:15,代码来源:TwitterRateLimitStatus.cs

示例2: Test2

        public ActionResult Test2()
        {
            OAuthTokens tokens = new OAuthTokens { ConsumerKey = ConfigurationManager.AppSettings["TwitterToken"], ConsumerSecret = ConfigurationManager.AppSettings["TwitterTokenSecret"] };

            var accounts = Accounts.Get().Select();
            foreach (var a in accounts)
            {
                if (a.Type == AccountType.Twitter)
                {
                    tokens.AccessToken = a.TwKey;
                    tokens.AccessTokenSecret = a.TwSecret;
                    TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, "Hello, #Twitterizer");
                    if (tweetResponse.Result == RequestResult.Success)
                    {
                        // Tweet posted successfully!
                    }
                    else
                    {
                        // Something bad happened
                    }
                }
            }

            return null;
        }
开发者ID:Otegaman,项目名称:lehavi-sap,代码行数:25,代码来源:TestController.cs

示例3: GetMutualFriends

        private static IEnumerable<TwitterUser> GetMutualFriends(OAuthTokens tokens)
        {
            var friends = TwitterFriendship.FriendsIds(tokens);
            var followers = TwitterFriendship.FollowersIds(tokens);

            var userIds = (from
                               friendId in friends.ResponseObject
                           join
                               followerId in followers.ResponseObject
                               on friendId equals followerId
                           select friendId).ToArray();

            var lookupOptions = new LookupUsersOptions();
            var users = new List<TwitterUser>();
            for (int i = 0; i < userIds.Length; i ++)
            {
                lookupOptions.UserIds.Add(userIds[i]);
                if (lookupOptions.UserIds.Count() >= 100 || i + 1 == userIds.Length)
                {
                    users.AddRange(TwitterUser.Lookup(tokens, lookupOptions).ResponseObject);
                    lookupOptions.UserIds.Clear();
                }
            }
            return users;
        }
开发者ID:kavallo,项目名称:twitter.GetFriends,代码行数:25,代码来源:Program.cs

示例4: Start

        public void Start()
        {
            //TileService.Add<TwitterView>(new TileData
            //{
            //    Title = "Peeps",
            //    BackgroundImage = new Uri("pack://siteoforigin:,,,/Resources/Tiles/MB_0005_weather1.png")
            //});

            Task.Factory.StartNew(() =>
            {
                OAuthTokens tokens = new OAuthTokens();
                tokens.AccessToken = "478840940-tgD2Fp5NWXpDPGWyrHTxIjroDODe6F9r8JEkabQ";
                tokens.AccessTokenSecret = "Jo4fgjtkYBPTfyuigi3slqOo7lVer7rLXwj6rWs";
                tokens.ConsumerKey = "O6MTEfpHhHfhnBr4PuVmlw";
                tokens.ConsumerSecret = "lDZgfovK9FEtn8MBsTpGPn8WvuTbGal2yBD4kHLgI";

                StreamOptions options = new StreamOptions();
                Stream = new TwitterStream(tokens, "v1", options);
                Stream.StartUserStream(Friends,
                                       Stopped,
                                       Created,
                                       Deleted,
                                       DirectMessageCreated,
                                       DirectMessageDeleted,
                                       Callback);
                Radio.CurrentTrackChanged += RadioOnCurrentTrackChanged;
            })
            .ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    Logger.Log(task.Exception.ToString(), Category.Exception, Priority.Medium);
                }
            });
        }
开发者ID:kristian-pettersen,项目名称:torshify-r4dio,代码行数:35,代码来源:TwitterHandler.cs

示例5: AjaxSaveToDB

        //
        // GET: /Home/
        public string AjaxSaveToDB()
        {
            if (Session["LoggedASP"] != null)
            {
                TimelineOptions options = new TimelineOptions();

                options.Count = 200;
                options.IncludeRetweets = true;

                OAuthTokens token = new OAuthTokens();
                token.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
                token.ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
                token.AccessToken = ((User)Session["LoggedUser"]).TwitterToken;
                token.AccessTokenSecret = ((User)Session["LoggedUser"]).TwitterTokenSecret;

                TwitterResponse<TwitterStatusCollection> truc = TwitterTimeline.HomeTimeline(token, options);

                TweetEntity tweetEntity = new TweetEntity();

                tweetEntity.RemoveTweetFromOwner(((User)Session["LoggedUser"]).ID);

                foreach (var item in truc.ResponseObject)
                {
                    //int lol = ;

                    tweetEntity.AddTweet(item.Id, item.Text, item.User.ScreenName, item.User.ProfileImageLocation, ((User)Session["LoggedUser"]).ID, ((int)((TimeSpan)(item.CreatedDate - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime())).TotalSeconds));
                }
                return "Success";
            }
            else
                return "Fail";
        }
开发者ID:fantattitude,项目名称:Tweetasse,代码行数:34,代码来源:HomeController.cs

示例6: TwitterSearchStream

        public TwitterSearchStream(TwitterProtocolManager protocolManager,
                                   GroupChatModel chat, string keyword,
                                   OAuthTokens tokens, WebProxy proxy)
        {
            if (protocolManager == null) {
                throw new ArgumentNullException("protocolManager");
            }
            if (chat == null) {
                throw new ArgumentNullException("chat");
            }
            if (keyword == null) {
                throw new ArgumentNullException("keyword");
            }
            if (tokens == null) {
                throw new ArgumentNullException("tokens");
            }

            ProtocolManager = protocolManager;
            Session = protocolManager.Session;
            Chat = chat;

            var options = new StreamOptions();
            options.Track.Add(keyword);

            Stream = new TwitterStream(tokens, null, options);
            Stream.Proxy = proxy;
            Stream.StartPublicStream(OnStreamStopped, OnStatusCreated, OnStatusDeleted, OnEvent);

            MessageRateLimiter = new RateLimiter(5, TimeSpan.FromSeconds(5));
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:30,代码来源:TwitterSearchStream.cs

示例7: frmPrincipal

        public frmPrincipal(Twitterizer.OAuthTokens oauth_tokens)
        {
            //Construtor que recebe o Token do Twitterizer

            TOKEN = oauth_tokens;
            InitializeComponent();
        }
开发者ID:AmadeuJunior,项目名称:LPOO,代码行数:7,代码来源:frmTeste.cs

示例8: Tweet

        /// <summary>
        /// Tweets the given message and image; returns the result.
        /// </summary>
        /// <param name="message"></param>
        public static bool Tweet( string message, byte[] resource )
        {
            // Check if we need to authenticate first
            if ( string.IsNullOrEmpty( Configuration.CurrentSettings.TwitterAccessToken ) || string.IsNullOrEmpty( Configuration.CurrentSettings.TwitterAccessSecret ) )
                AcquireAuthentication( );

            // Build tokens...
            OAuthTokens tokens = new OAuthTokens
            {
                 ConsumerKey = ConsumerKey,
                 ConsumerSecret = ConsumerSecret,
                 AccessToken = Configuration.CurrentSettings.TwitterAccessToken,
                 AccessTokenSecret = Configuration.CurrentSettings.TwitterAccessSecret
             };

            TwitterResponse<TwitterStatus> response = TwitterStatus.UpdateWithMedia( tokens, message, resource );
            if ( response.Result == RequestResult.Success )            
                log.Info( "Tweeted: " + message );
            else
            {
                if ( response.Result == RequestResult.Unauthorized )
                    AcquireAuthentication( );

                log.Error( "Error during tweet: " + response.Result + " / " + response.ErrorMessage );
                return false;
            }

            return true;
        }
开发者ID:phillco,项目名称:HellForge,代码行数:33,代码来源:TwitterPoster.cs

示例9: RetrieveTwitts

        public IList<NakedTwitt> RetrieveTwitts(int count)
        {
            List<NakedTwitt> result = new List<NakedTwitt>();

            try
            {
                OAuthTokens tokens = new OAuthTokens()
                                         {
                                             AccessToken = AccessToken,
                                             AccessTokenSecret = AccessTokenSecret,
                                             ConsumerKey = ConsumerKey,
                                             ConsumerSecret = ConsumerSecret
                                         };

                TimelineOptions timelineOptions = new TimelineOptions()
                                                      {
                                                          Count = count,
                                                          IncludeRetweets = false
                                                      };

                TwitterResponse<TwitterStatusCollection> homeTimeline = TwitterTimeline.HomeTimeline(tokens,
                                                                                                     timelineOptions);
                result =
                    homeTimeline.ResponseObject.Select(
                        x => new NakedTwitt() {StringId = x.StringId, Text = x.Text, CreatedDate = x.CreatedDate})
                                .ToList();

                return result;
            }
            catch (Exception ex)
            {
                log.Error("Error retrieving twitts from the internet", ex);
                return result;
            }
        }
开发者ID:Jacobeom,项目名称:git-first,代码行数:35,代码来源:TwittsProvider.cs

示例10: Callback

        public ActionResult Callback(string oauth_token, string oauth_verifier, bool popup = false)
        {
            OAuthTokenResponse tokens = OAuthUtility.GetAccessToken(
                App.ConsumerKey, App.ConsumerSecret, oauth_token, oauth_verifier);

            OAuthTokens oauthTokens = new OAuthTokens();
            oauthTokens.AccessToken = tokens.Token;
            oauthTokens.AccessTokenSecret = tokens.TokenSecret;
            oauthTokens.ConsumerKey = App.ConsumerKey;
            oauthTokens.ConsumerSecret = App.ConsumerSecret;

            TwitterUser user = TwitterUser.Show(oauthTokens, tokens.UserId).ResponseObject;

            Tweeter tweeter = TweeterRepository.FromTwitterId((long)user.Id);

            if (tweeter != null)
            {
                tweeter = Mapper.Map<TwitterUser, Tweeter>(user, tweeter);
            }
            else
            {
                tweeter = Mapper.Map<TwitterUser, Tweeter>(user);
                TweeterRepository.Save(tweeter);
            }

            string secureCode = SecurityUtils.GenerateSecureKey(KeyStrength._512bit);

            HttpCookie loginCookie = new HttpCookie("Login_Cookie");

            loginCookie.Values["ID"] = tweeter.TwitterId.ToString();
            loginCookie.Values["Code"] = secureCode;
            loginCookie.Expires = DateTime.UtcNow.AddDays(30.0);
            loginCookie.HttpOnly = true;

            Response.Cookies.Add(loginCookie);

            PersistentLogin login = new PersistentLogin(tweeter);
            login.SecureKey = secureCode;
            login.LastLoginDate = DateTime.UtcNow;
            tweeter.PersistentLogins.Add(login);

            TweeterRepository.Save(tweeter);

            Tweeter = tweeter;

            if (!popup)
            {
                string referrerUrl = GetTempReferrerUrl();
                if (!String.IsNullOrWhiteSpace(referrerUrl))
                {
                    return Redirect(referrerUrl);
                }

                return RedirectToAction("Latest", "Display");
            }
            else
            {
                return View("Complete", Tweeter);
            }
        }
开发者ID:Sironfoot,项目名称:T3ME,代码行数:60,代码来源:OAuthController.cs

示例11: VerifyButton_Click

    protected void VerifyButton_Click(object sender, EventArgs e)
    {
        ResultLabel.Visible = true;

        OAuthTokens tokens = new OAuthTokens()
        {
            AccessToken = AKTextBox.Text,
            AccessTokenSecret = ASTextBox.Text,
            ConsumerKey = CKTextBox.Text,
            ConsumerSecret = CSTextBox.Text
        };

        TwitterResponse<TwitterErrorDetails> twitterResponse = TwitterAccount.EndSession(tokens, null);

        if (twitterResponse.Result == RequestResult.Success)
        {
            ResultLabel.Text = string.Format("Success! Verified as {0}", twitterResponse.ResponseObject.ErrorMessage);
            ResultLabel.CssClass = "ResultLabelSuccess";
        }
        else
        {
            ResultLabel.Text = string.Format("Failed! \"{0}\"", twitterResponse.ErrorMessage ?? "Not Authorized.");
            ResultLabel.CssClass = "ResultLabelFailed";
        }
    }
开发者ID:JamesConsidine,项目名称:twintie,代码行数:25,代码来源:logout.aspx.cs

示例12: VerifyCredentials

        /// <summary>
        /// Attempts to verify the supplied credentials.
        /// </summary>
        /// <param name="tokens">The tokens.</param>  
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The callback or anonymous funtion.</param>
        /// <returns>
        /// The user, as a <see cref="TwitterUser"/>
        /// </returns>       
        public static IAsyncResult VerifyCredentials(OAuthTokens tokens, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterUser>> function)
        {
#if !SILVERLIGHT
            Func<OAuthTokens, TwitterResponse<TwitterUser>> methodToCall = TwitterAccount.VerifyCredentials;

            return methodToCall.BeginInvoke(
                tokens,
                result => 
                {
                    result.AsyncWaitHandle.WaitOne(timeout);
                    try
                    {
                        function(methodToCall.EndInvoke(result).ToAsyncResponse());
                    }
                    catch (Exception ex)
                    {
                        function(new TwitterAsyncResponse<TwitterUser>() { Result = RequestResult.Unknown, ExceptionThrown = ex });
                    }
                },
                null);
#else            
            ThreadPool.QueueUserWorkItem((x) =>
                {
                    function(TwitterAccount.VerifyCredentials(tokens).ToAsyncResponse<TwitterUser>());  
                });
            return null;
#endif
        }
开发者ID:zippy1981,项目名称:Twitterizer,代码行数:37,代码来源:TwitterAccountAsync.cs

示例13: Tweet

        public static void Tweet(string message)
        {
            throw new NotSupportedException("Remove this when you're ready to Tweet!");
            try
            {
                if (ConfigManager.CurrentUserSpecific.IsValidated)
                    return;
                if (ConfigManager.CurrentUserSpecific.IsEnabled == false)
                    return;
                var currConfig = ConfigManager.CurrentUserSpecific;
                OAuthTokens tokens = new OAuthTokens
                                         {
                                             ConsumerKey = ConsumerKey,
                                             ConsumerSecret = ConsumerSecret,
                                             AccessToken = currConfig.AccessToken,
                                             AccessTokenSecret = currConfig.AccessSecret
                                         };

                TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, message);
                if (tweetResponse.Result == RequestResult.Success)
                {
                    // Tweet posted successfully!
                }
                else
                {
                    // Something bad happened
                }
            } catch // Very silent
            {

            }
        }
开发者ID:kallex,项目名称:MSTechDays2012Demos,代码行数:32,代码来源:TwitterFeedSupport.cs

示例14: GetTwittUser

        /*Retrieve a twitt user from a given screen name, see https://dev.twitter.com/docs/api/1/get/users/show*/
        public static TwittUser GetTwittUser(string screenName)
        {
            OAuthTokens tokens = new OAuthTokens();
            tokens.ConsumerKey = "Removed from github example";
            tokens.ConsumerSecret = "Removed from github example";
            tokens.AccessToken = "Removed from github example";
            tokens.AccessTokenSecret = "Removed from github example";

            var list = new List<string>();

            LookupUsersOptions options = new LookupUsersOptions(){UseSSL = true, APIBaseAddress="http://api.twitter.com/1.1/"};
            options.ScreenNames.Add(screenName);

            TwitterResponse<TwitterUserCollection> res = TwitterUser.Lookup(tokens, options);
            TwitterUserCollection users = res.ResponseObject;
            TwitterUser user = users.First();

            if (user == null) return null;

            TwittUser tu = new TwittUser(
                user.Id.ToString(),
                user.Name,
                user.ScreenName,
                user.Location,
                user.Description);
            return tu;
        }
开发者ID:Pripman,项目名称:TwitterApp,代码行数:28,代码来源:TwittManager.cs

示例15: GetTwittStatusList

        public static List<TwittStatus> GetTwittStatusList(string screenName)
        {
            OAuthTokens tokens = new OAuthTokens();
            tokens.ConsumerKey = "zPY6AwGePUOWAk0fTvrhZhgzg";
            tokens.ConsumerSecret = "VzBhawh55oWWocdDrn4MdLfSPcG5ypf7scFJZGrSyWkSuJAjDA";
            tokens.AccessToken = "50022775-djO15EBUOMT76TXswKa0XvwfDmM12Xo27NZmxyhwr";
            tokens.AccessTokenSecret = "QqpnD1Mq4AEQYW48NyauzAMDRGDyQ0QCTQjWNRFyFCZkz";

            var list = new List<TwittStatus>();

            UserTimelineOptions options = new UserTimelineOptions();
            options.APIBaseAddress = "https://api.twitter.com/1.1/";
            options.Count = 20;
            options.UseSSL = true;
            options.ScreenName = screenName;
            var resp = TwitterTimeline.UserTimeline (tokens, options);
            TwitterStatusCollection tweets = resp.ResponseObject;

            if (tweets == null) return null;

            foreach (var status in tweets) {
                TwittStatus ts = new TwittStatus (
                    status.Id.ToString (),
                    status.Text,
                    status.User.Id.ToString(),
                    status.CreatedDate.ToString());
                list.Add (ts);
            }
            return list;
        }
开发者ID:Pripman,项目名称:TwitterApp,代码行数:30,代码来源:TwittManager.cs


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