Skip to content

Instantly share code, notes, and snippets.

@waf
Created May 27, 2015 12:19
Show Gist options
  • Save waf/befaf6cc309dae69a2ef to your computer and use it in GitHub Desktop.
Save waf/befaf6cc309dae69a2ef to your computer and use it in GitHub Desktop.
connect to Slack API
//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