aboutsummaryrefslogtreecommitdiffstats
path: root/examples/hubzilla-channel-stream.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hubzilla-channel-stream.rs')
-rw-r--r--examples/hubzilla-channel-stream.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/hubzilla-channel-stream.rs b/examples/hubzilla-channel-stream.rs
new file mode 100644
index 0000000..f0cab19
--- /dev/null
+++ b/examples/hubzilla-channel-stream.rs
@@ -0,0 +1,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...");
+ }
+ }
+}