aboutsummaryrefslogtreecommitdiffstats
path: root/examples/hubzilla-channel-stream.rs
blob: f0cab19c72267a9003d048f944cadecf7dae50ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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...");
        }
    }
}