简体   繁体   中英

Get Tweets of all users using TweetSharpAPI

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!

What you want to do is interface with the Twitter Streaming API . This API allows you to open a persistent connection with Twitter and Twitter will then stream results to you as they come in.

Twitter Streaming API图

(taken from the Twitter Streaming API page)

That said, TweetSharp doesn't currently support the Streaming API. However, it's not difficult to open a connection to Twitter in .NET and process the responses as they're received (however, I'd recommend using the HttpClient class to process this asynchronously, as well as using a proper JSON parsing library, like Json.NET ).

Note the third column in the diagram "Streaming connection process", specifically the middle part:

Receives streamed Tweets, performs processing and stores result

As well as the "HTTP Server process" column:

Server pulls processed result from data store and renders view.

While not explicitly mentioned, you are best off just persisting the Tweet as you get it into a data store and then having another process handle the Tweets; the volume of Tweets you might get is so high that performing any processing when you get the Tweet will backlog the receiving of new Tweets.

For your specific case, you'll want to access the Public Streams with a POST filter of "dumbledore".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM