aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--examples/hubzilla-channel-stream.rs26
2 files changed, 28 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1c2f542..88e8ba7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,4 +7,6 @@ authors = ["haraldei"]
reqwest = "0.8"
[dev-dependencies]
+dotenv = "0.13"
mockito = "0.12"
+serde_json = "1.0"
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...");
+ }
+ }
+}