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


C# TwitterService.ListFavoriteTweets方法代码示例

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


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

示例1: Load

        protected void Load(TwitterResource resource)
        {
            var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);

            switch (resource.Type)
            {
                case ResourceType.Home:
                    service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Mentions:
                    service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions { Count = 1, IncludeEntities = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Messages:
                    service.ListDirectMessagesReceived(new ListDirectMessagesReceivedOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Favorites:
                    service.ListFavoriteTweets(new ListFavoriteTweetsOptions { Count = 1 }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.List:
                    service.ListTweetsOnList(new ListTweetsOnListOptions
                    {
                        IncludeRts = false,
                        Count = 1,
                        OwnerScreenName = resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                        Slug = resource.Data.Substring(resource.Data.IndexOf('/') + 1)
                    }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Search:
                    service.Search(new SearchOptions { Count = 1, IncludeEntities = true, Q = resource.Data }, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Tweets:
                    service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { Count = 1, ScreenName = resource.Data, IncludeRts = true }, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
            }
        }
开发者ID:rafaelwinter,项目名称:Ocell,代码行数:35,代码来源:BaseScheduledAgent.cs

示例2: 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

示例3: PostToReader

        public static List<string> PostToReader(string _consumerKey, string _consumerSecret, string _accessToken, string _accessTokenSecret, string gUsername, string gPassword, bool chkTweets, bool chkFavorites, bool chkRetweets,  bool chkLinks, bool chkNoLinks)
        {
            List<string> res = new List<string>();
            GoogleReader gr = new GoogleReader(gUsername, gPassword);
            var serviceReader = new TwitterService(_consumerKey, _consumerSecret);
            serviceReader.AuthenticateWith(_accessToken, _accessTokenSecret);
            Regex urlfind = new Regex("((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|])", RegexOptions.IgnoreCase);

            List<TwitterStatus> mytweets =null;
            List<TwitterStatus> favorites=null;
            List<TwitterStatus> retweets =null;
            if (chkTweets)    mytweets  = serviceReader.ListTweetsOnUserTimeline(5).ToList();
            if (chkFavorites) favorites = serviceReader.ListFavoriteTweets(5).ToList();
            if (chkRetweets)  retweets  = serviceReader.ListRetweetsByMe(5).ToList();

            List<TwitterStatus> alltweets = new List<TwitterStatus>();
            if (mytweets != null) alltweets.AddRange(mytweets);
            if (favorites != null) alltweets.AddRange(favorites);
            if (retweets != null) alltweets.AddRange(retweets);

            foreach (var tweet in alltweets)
            {
                if (hassent(tweet.Id.ToString())) { continue; }
                Match thematch = urlfind.Match(tweet.Text);
                if (thematch.Success)
                {
                    if (chkLinks)
                    {
                        string theshorturl = thematch.Groups[1].Value;
                        string theurl = thematch.Groups[1].Value;
                        try
                        {
                            string longurlxml = c.DownloadString("http://api.unshort.me/?r=" + theurl);
                            Regex resUrl = new Regex("<resolvedURL>(.*?)</resolvedURL>");
                            Match resolved = resUrl.Match(longurlxml);
                            if (resolved.Success)
                            {
                                theurl = resolved.Groups[1].Value;
                            }
                        }
                        catch
                        {

                        }
                        string title;
                        string content = embed(theurl, out title);
                        gr.post(content, theurl, title, tweet.Text.Replace(theshorturl, "").Trim());
                        AddID(tweet.Id.ToString(), tweet.Text);
                    }

                }
                else if (chkNoLinks)
                {
                    gr.post("", "http://twitter.com/" + tweet.User.ScreenName + "/status/" + tweet.Id, "from twitter", tweet.Text.Trim());
                    AddID(tweet.Id.ToString(), tweet.Text);

                }
                res.Add( DateTime.Now.ToShortTimeString() + ": " + tweet.Text);
            }
            return res;
        }
开发者ID:vrokolos,项目名称:Tweet2Reader,代码行数:61,代码来源:Utils.cs

示例4: Load

        protected void Load(TwitterResource resource)
        {
            var service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret, resource.User.Key, resource.User.Secret);

            switch (resource.Type)
            {
                case ResourceType.Home:
                    service.ListTweetsOnHomeTimeline(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Mentions:
                    service.ListTweetsMentioningMe(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Messages:
                    service.ListDirectMessagesReceived(1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Favorites:
                    service.ListFavoriteTweets((status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.List:
                    service.ListTweetsOnList(resource.Data.Substring(1, resource.Data.IndexOf('/') - 1),
                            resource.Data.Substring(resource.Data.IndexOf('/') + 1), 1, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Search:
                    service.Search(resource.Data, 1, 20, (status, response) => ReceiveTweetable(status.Statuses.Cast<ITweetable>(), response, resource));
                    break;
                case ResourceType.Tweets:
                    service.ListTweetsOnSpecifiedUserTimeline(resource.Data, 1, true, (status, response) => ReceiveTweetable(status.Cast<ITweetable>(), response, resource));
                    break;
            }
        }
开发者ID:Quertz,项目名称:Ocell,代码行数:30,代码来源:ScheduledAgent.cs


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