chiark / gitweb /
First demo of a streaming API working.
authorSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 11:37:08 +0000 (11:37 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 11:37:08 +0000 (11:37 +0000)
Had to bodgily pull in the Python version's auth data for this, but
it's a start. I can sort that part out properly later.

src/main.rs

index 9804632eba533db5a72c22bc2c1e353e8b08cf98..cc81e6344889760beaaec38f08097387e354448e 100644 (file)
@@ -1,10 +1,18 @@
-use mastodonochrome::types::*;
+// use mastodonochrome::types::*;
 
 fn main() {
+    let auth = std::fs::read_to_string(
+        "/home/simon/.config/mastodonochrome/auth").unwrap();
+    dbg!(&auth);
+    let auth: serde_json::Value = serde_json::from_str(&auth).unwrap();
+    dbg!(&auth);
+    let auth = &auth["user_token"].as_str().unwrap();
+    dbg!(&auth);
+
     let client = reqwest::blocking::Client::new();
-    let body = client.get(
-        "https://hachyderm.io/api/v1/statuses/111602135142646031")
-        .send().unwrap().text().unwrap();
-    let st: Status = serde_json::from_str(&body).unwrap();
-    dbg!(st);
+    let mut req = client.get(
+        "https://hachyderm.io/api/v1/streaming/user")
+        .bearer_auth(auth)
+        .send().unwrap();
+    req.copy_to(&mut std::io::stdout());
 }