流媒体推文搜索TweetSharp

时间:2014-01-11 02:19:52

标签: c# twitter tweetsharp

我是Tweet Sharp和C#的新手。我想知道如何流式传输特定哈希标签的实时推文。

我一直在使用像ListTweetsOnHomeTimeline这样的方法来返回我的用户主页的一些推文但是它们不是真的

2 个答案:

答案 0 :(得分:1)

据我所知,Tweet Sharp已经停产。但是,如果您需要第三方库https://linqtotwitter.codeplex.com/

,我听过linqtotwitter的好消息

答案 1 :(得分:1)

我很长一段时间没有使用TweetSharp,并且不记得如何流式传输某些哈希标记,但要返回用户流,您可以尝试使用此方法:

    public void StreamFromUser()
    {
        var block = new AutoResetEvent(false);

        var service = GetAuthenticatedService();

        service.StreamUser((streamEvent, response) =>
        {
            if (streamEvent is TwitterUserStreamEnd)
            {
                block.Set();
            }

            if (response.StatusCode == 0)
            {
                if (streamEvent is TwitterUserStreamFriends)
                {
                    var friends = (TwitterUserStreamFriends)streamEvent;
                }

                if (streamEvent is TwitterUserStreamEvent)
                {
                    var @event = (TwitterUserStreamEvent)streamEvent;
                }

                if (streamEvent is TwitterUserStreamStatus)
                {
                    var tweet = ((TwitterUserStreamStatus)streamEvent).Status;
                }

                if (streamEvent is TwitterUserStreamDirectMessage)
                {
                    var dm = ((TwitterUserStreamDirectMessage)streamEvent).DirectMessage;
                }

                if (streamEvent is TwitterUserStreamDeleteStatus)
                {
                    var deleted = (TwitterUserStreamDeleteStatus)streamEvent;
                }

                if (streamEvent is TwitterUserStreamDeleteDirectMessage)
                {
                    var deleted = (TwitterUserStreamDeleteDirectMessage)streamEvent;
                }
            }
            else
            {
                Assert.Ignore("Stream responsed with status code: {0}", response.StatusCode);
            }
        });

        block.WaitOne();
        service.CancelStreaming();
    }