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


C# IUserSession.GetHomeTimeline方法代码示例

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


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

示例1: DoTimelineTest

        public async Task<bool> DoTimelineTest(IUserSession session, List<int> testSeq)
        {
            var successStatus = true;
            try
            {
                // 1
                if (testSeq.Contains(1))
                {
                    ConsoleOutput.PrintMessage("7.1 Timeline\\GetMentions", ConsoleColor.Gray);
                    var timeline1 = await session.GetMentions(count: 100);

                    if (timeline1.OK)
                    {
                        foreach (var tweet in timeline1)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("From: {0} // Message: {1}", tweet.User.ScreenName, tweet.Text));
                        }
                    }
                    else
                        successStatus = false;
                }

                // 2
                if (testSeq.Contains(2))
                {
                    ConsoleOutput.PrintMessage("7.2 Timeline\\GetUserTimeline", ConsoleColor.Gray);
                    var timeline2 = await session.GetUserTimeline(screenName: "shiftkey", count: 20);

                    if (timeline2.OK)
                    {
                        foreach (var tweet in timeline2)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("From: {0} // Message: {1}", tweet.User.ScreenName, tweet.Text));
                        }
                    }
                    else
                        successStatus = false;
                }


                // 3
                if (testSeq.Contains(3))
                {
                    ConsoleOutput.PrintMessage("7.3 Timeline\\GetHomeTimeline", ConsoleColor.Gray);
                    var timeline3 = await session.GetHomeTimeline(count: 30);

                    if (timeline3.OK)
                    {
                        foreach (var tweet in timeline3)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("From: {0} // Message: {1}", tweet.User.ScreenName, tweet.Text));
                        }
                    }
                    else
                        successStatus = false;
                }


                // 4
                if (testSeq.Contains(4))
                {
                    ConsoleOutput.PrintMessage(
                        "7.4 Timeline\\GetHomeTimeline - Paging Forward, getting new tweets, with ID mechanism",
                        ConsoleColor.Gray);
                    var timeline4 = await session.GetHomeTimeline(count: 10);
                    long largestid = 0;
                    long smallestid = 0;

                    if (timeline4.OK)
                    {
                        smallestid = timeline4.ToList()[0].Id;
                        foreach (var tweet in timeline4)
                        {
                            ConsoleOutput.PrintMessage(
                                String.Format("ID: {0} // From: {1} // Message: {2}", tweet.Id, tweet.User.ScreenName,
                                    tweet.Text));
                            if (tweet.Id > largestid)
                                largestid = tweet.Id;
                            if (tweet.Id < smallestid)
                                smallestid = tweet.Id;
                        }
                        ConsoleOutput.PrintMessage(
                            String.Format(" LargestID: {0} // SmallestID: {1}", largestid, smallestid));

                        ConsoleOutput.PrintMessage("Waiting 20 seconds");
                        await Task.Delay(TimeSpan.FromSeconds(20));

                        ConsoleOutput.PrintMessage("Now Updating Home Timeline, should add newer messages");
                        var timeline41 = await session.GetHomeTimeline(sinceId: largestid, count: 10);
                        if (timeline41.OK)
                        {
                            foreach (var tweet in timeline41)
                            {
                                ConsoleOutput.PrintMessage(
                                    String.Format("ID: {0} // From: {1} // Message: {2}", tweet.Id,
                                        tweet.User.ScreenName, tweet.Text));
                                if (tweet.Id > largestid)
//.........这里部分代码省略.........
开发者ID:gerryaobrien,项目名称:BoxKite.Twitter,代码行数:101,代码来源:07TimelineLiveFireTests.cs


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