3

I have implemented a method which manually scrapes the Search Twitter page and gets the tweets on different pages. But since there is a fast refresh rate, the method triggers an exception. Therefore I have decided to use TweetSharp API instead

 var search = FluentTwitter.CreateRequest()
                           .AuthenticateAs(TWITTER_USERNAME, TWITTER_PASSWORD)
                           .Users()
                           .SearchFor("dumbledore");

var result = search.Request();
var users = result.AsUsers();

this code was on the site. Does anyone know how I can avoid giving my credentials and retrieve from all users and not just the ones I have as friends?

Thanks!

4

1 回答 1

0

您要做的是与Twitter Streaming API交互。此 API 允许您打开与 Twitter 的持久连接,然后 Twitter 将在结果进入时将结果流式传输给您。

Twitter Streaming API 图

(取自 Twitter 流 API 页面)

也就是说,TweetSharp目前不支持 Streaming API。但是,在 .NET 中打开与 Twitter 的连接并在收到响应时处理它们并不难(但是,我建议使用HttpClient该类来异步处理它,以及使用适当的 JSON 解析库,如Json .NET)。

注意图中“流式连接过程”中的第三列,特别是中间部分:

接收流式推文,执行处理并存储结果

以及“HTTP Server 进程”一栏:

服务器从数据存储中提取处理后的结果并呈现视图。

虽然没有明确提及,但最好将推文保存到数据存储中,然后让另一个进程处理推文;您可能获得的推文数量如此之多,以至于在您获得推文时执行任何处理都会积压接收新推文。

对于您的具体情况,您需要使用“dumbledore”的POST 过滤器访问公共流。

于 2012-08-08T13:52:47.227 回答