aboutsummaryrefslogblamecommitdiffstats
path: root/examples/hubzilla-channel-stream.rs
blob: f0cab19c72267a9003d048f944cadecf7dae50ff (plain) (tree)

























                                                                                          
extern crate zotapi;
extern crate dotenv;
extern crate serde_json;

use dotenv::dotenv;
use serde_json::Value;
use std::env;

fn main() {
    dotenv().ok();
    let site = env::var("SITE").unwrap();
    let user = env::var("USER").unwrap();
    let password = env::var("PASSWORD").unwrap();
    let client = zotapi::client(&site, &user, &password);

    match serde_json::from_str(&client.channel_stream()).unwrap() {
        Value::Array(v) => {
            for item in v.into_iter() {
                println!("{} {} {}", item["title"], item["type"], item["author"]["name"]);
            }
        },
        _ => {
            println!("Expected an array, really...");
        }
    }
}