TweetSharp C#API搜索仅返回前100条推文 [英] TweetSharp C# api Search only returns first 100 tweets

查看:140
本文介绍了TweetSharp C#API搜索仅返回前100条推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用TweetSharp api来处理twitter. 我用来在Twitter上搜索Tweets的以下代码.问题是它返回的信息不超过前100条.

I've used TweetSharp api to work with twitter. The following code I am using to search Tweets on twitter. Problem is it does not returning more than first 100 Tweets.

     public List<TwitterStatus> SearchTweetsBySearchText(int intTotalRec,string searchText)
    {
        List<TwitterStatus> lstTwitterStatusRet = new List<TwitterStatus>();
        UpdateResetTimeForApplicationForSearch("Moderator");
        TwitterApplicationModel twitterApplication = new TwitterApplicationModel();
        twitterApplication = TwitterApplicationBL.GetApplicationInstanceForSearch("Moderator");
        if (twitterApplication != null)
        {
            TwitterService service = new TwitterService(twitterApplication.ConsumerKey, twitterApplication.ConsumerSecret, twitterApplication.AccessToken, twitterApplication.AccessTokenSecret);

            var twitterSearchResult = service.Search(new SearchOptions { Q = searchText, Count = intTotalRec });

            if (service != null)
            {
                if (service.Response != null)
                {
                    if (service.Response.RateLimitStatus.RemainingHits <= 0)
                    {
                        TwitterApplicationBL.UpdateApplicationRemainingHitsForSearch(twitterApplication.TwitterApplicationID, false, service.Response.RateLimitStatus.ResetTime);
                    }
                }
            }


            if (twitterSearchResult != null)
            {
                lstTwitterStatusRet = ((List<TwitterStatus>)twitterSearchResult.Statuses);
                foreach (TwitterStatus objTwitterStatus in lstTwitterStatusRet)
                {
                    objTwitterStatus.CreatedDate = objTwitterStatus.CreatedDate.AddHours(-4);
                }
            }
        }
        return lstTwitterStatusRet;

    }

任何人都可以建议可以做什么吗?

Can any one suggest what can be done?

推荐答案

Twitter搜索只能追溯5到7天或1,500条推文,以先到者为准.搜索API相同.到目前为止,任何其他鸣叫都无法通过任何已知方法获得. Twitter有它们,但是没有办法得到它们.

Twitter search only goes back 5 - 7 days, or 1,500 tweets, whichever comes first. The search API is the same. Any tweets beyond that are not available through any known method (as of now). Twitter has them, but there is no way to get them.

在您的情况下,一个搜索永远不会获得超过100个结果.因此,您需要使用"next_results"部分中的max_id进行另一次搜索

And in your case, one can never get more than 100 results in from a search. So, you need to issue another search using the max_id in the "next_results" section

有关分页的更多信息,请点击此处 https://dev.twitter.com/docs/working-with-timelines

more info on paging here https://dev.twitter.com/docs/working-with-timelines

快乐编码.. :)

这篇关于TweetSharp C#API搜索仅返回前100条推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆