twitter-stream-message

Crates.iotwitter-stream-message
lib.rstwitter-stream-message
version0.3.0
sourcesrc
created_at2017-06-16 09:59:10.492755
updated_at2018-06-01 04:12:39.67309
descriptionTypes for Twitter Streaming API's messages.
homepagehttps://github.com/dmizuk/twitter-stream-rs
repositoryhttps://github.com/dmizuk/twitter-stream-rs
max_upload_size
id19181
size85,211
Daiki Mizukami (tesaguri)

documentation

https://docs.rs/twitter-stream/0.3.0/twitter_stream-message/

README

Twitter Stream

Build Status Current Version Documentation

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();
}
Commit count: 397

cargo fmt