4 releases (2 breaking)
Uses old Rust 2015
0.3.0 | Jun 1, 2018 |
---|---|
0.2.1 | May 17, 2018 |
0.2.0 | Jun 21, 2017 |
0.1.0 | Jun 16, 2017 |
#4 in #listening
41 downloads per month
82KB
1.5K
SLoC
Twitter Stream
A Rust library for listening on Twitter Streaming API.
Requirements
This library requires Rust 1.21 or later.
Usage
Add this to your Cargo.toml
:
[dependencies]
twitter-stream = "0.5"
and this to your crate root:
extern crate twitter_stream;
Here is a basic example that prints public mentions @Twitter in JSON format:
extern crate futures;
extern crate tokio_core;
extern crate twitter_stream;
use futures::{Future, Stream};
use tokio_core::reactor::Core;
use twitter_stream::{Token, TwitterStreamBuilder};
fn main() {
let token = Token::new("consumer_key", "consumer_secret", "access_key", "access_secret");
let mut core = Core::new().unwrap();
let future = TwitterStreamBuilder::filter(&token).handle(&core.handle())
.replies(true)
.track(Some("@Twitter"))
.listen()
.flatten_stream()
.for_each(|json| {
println!("{}", json);
Ok(())
});
core.run(future).unwrap();
}
Dependencies
~1.6–2.6MB
~49K SLoC