aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-08-07 23:56:13 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-08-07 23:56:13 +0200
commit035fb7fd9ed8528a8076730f0aeab025fbc29f12 (patch)
tree60574fc55ec1c8bc76c805ee81aafe00f29a5df4 /examples
parent2a05b5a40a822f52ffcd1377aad9285d15da4d9f (diff)
downloadrust-zotapi-035fb7fd9ed8528a8076730f0aeab025fbc29f12.tar.gz
rust-zotapi-035fb7fd9ed8528a8076730f0aeab025fbc29f12.tar.bz2
rust-zotapi-035fb7fd9ed8528a8076730f0aeab025fbc29f12.zip
Add example of using the channel stream api.
Diffstat (limited to 'examples')
-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...");
+ }
+ }
+}