Created
May 27, 2015 12:19
-
-
Save waf/befaf6cc309dae69a2ef to your computer and use it in GitHub Desktop.
connect to Slack API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Cargo.toml: | |
[package] | |
name = "rustbot" | |
version = "0.1.0" | |
authors = ["wafuqua"] | |
[dependencies] | |
websocket = "~0.11.11" | |
hyper = "0.5.0" | |
serde = "0.4.0" | |
//main.rs: | |
extern crate hyper; | |
use hyper::Client; | |
use std::io::Read; | |
fn main() { | |
let token = "<my-slack-api-token>"; | |
let url = "https://slack.com/api/rtm.start?token=".to_string() + token; | |
let mut http = Client::new(); | |
let mut response = http.get(&url).send().unwrap(); | |
let mut body = String::new(); | |
response.read_to_string(&mut body).unwrap(); | |
println!("body {}", body); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment