开发者

How to access the tweet history conversation using TweetSharp?

I am trying to access a tweet conversation history using TweetSharp.

The requirement is like, if I use id of one tweet item it should return me the whole thread that followed before that tweet item.

But could not find such method exposed through TwittertService, where I can pass the current Tweet _id and get the conversation details.

I followed the following approach to get the collection (list) ie,

List<TwitterStatus> list = new List<TwitterStatus>();


private void GetReplied(TwitterStatus twitter, TwitterResponse twitterResponse)
{
    if (twitter.InReplyToStatusId != null)
    {
        long statusID = (long)twitter.InReplyToStatusId;
        this.ts.GetTweet(statusID, (twitterRecursive,
                                    twitterResponseRecursive) =>
                                    {
                                        list.Add(twitterRecursive);
                                        if (twitter.InReplyToStatusId != null)
                                        {
                                            this.GetReplied(twitterRecursive,
                                                            twitterResponseRecursive);
                                        }
                                    });
    }
    else
    {
        Debug.WriteLine(list.Count);
        foreach (TwitterStatus status in list)
        {
            Debug.WriteLine(status.Text);
        }
    }
}

this.ts.GetTweet(<tweet Id>, twitterResponse) =>
{
        list.Add(twitter);
 开发者_JAVA技巧       this.GetReplied(twitter, twitterResponse);
});

Just wanted to have your advice, on that. Do we have any such method with TweetSharp or any alternative approach can be implemented?

Really appreciate your help.


Yep, that's how you'll have to do it: start with a tweet and walk its in_reply_to_status_id chain.

One thing I do, although it may not be applicable to you, is check a local cache of tweets before fetching from Twitter to see if I already fetched the tweet being replied to.

As for libraries that make this easier, I don't know of any. Regardless of whether they expose a more streamlined method, under the covers they'll still have to perform the process that you implemented in your code.

To see how another library approached this task, take a look at this Twitterizer sample.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜