You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this library and I wish to filter by location boxes, but I'm not sure where to start. An example of each type of filter, or some way to connect the dots for users between the APIs and this library would be nice!
extern crate twitter_stream;
extern crate ini;
use twitter_stream::{Token, TwitterStreamBuilder};
use twitter_stream::rt::{self, Future, Stream};
use ini::Ini;
fn main() {
let conf = Ini::load_from_file("config.ini").expect("Unable to read config.ini");
let bounding = conf.section(Some("geo_bounding")).expect("No geo_bounding section found in config");
let bounds = vec![];
for bound in &["west", "south", "east", "north"] {
bounds.push(
bounding
.get(bound.to_owned()).expect(&format!("Unable to find value for '{}' in config", bound))
.parse::<f64>() .expect(&format!("Unable to parse value for '{}' as f64", bound))
);
}
let bounds = ((bounds[0], bounds[1]), (bounds[2], bounds[3]));
let future = TwitterStreamBuilder::filter(Token::new("consumer_key", "consumer_secret", "access_token", "access_secret",))
.locations(bounds)
.listen()
.unwrap()
.flatten_stream()
.for_each(|json| {
println!("{}", json);
Ok(())
})
.map_err(|e| println!("error: {}", e));
rt::run(future);
}
This is my best shot, but I get an error that I haven't been able to resolve:
26 | .locations(bounds)
| ^^^^^^^^^ the trait `std::convert::From<((f64, f64), (f64, f64))>` is not implemented for `std::option::Option<&[((f64, f64), (f64, f64))]>`
The text was updated successfully, but these errors were encountered:
Figured it out, just needed to change: let bounds = ((bounds[0], bounds[1]), (bounds[2], bounds[3]));
to let bounds = &[((bounds[0], bounds[1]), (bounds[2], bounds[3]))][..];
Maybe consider adding something like this code to the readme, so people don't get hung up on the type that locations takes like I did?
I am using this library and I wish to filter by location boxes, but I'm not sure where to start. An example of each type of filter, or some way to connect the dots for users between the APIs and this library would be nice!
This is my best shot, but I get an error that I haven't been able to resolve:
The text was updated successfully, but these errors were encountered: