commit 13050a1486de4eea69f03915e09d307cc965cedf Author: Anna Schumaker Date: Tue May 26 09:21:44 2015 -0400 Initial commit Call the api.test and auth.test methods using a token from the file "token" in the current directory. Signed-off-by: Anna Schumaker diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94bc20a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +token +*.sw* diff --git a/slackmail.py b/slackmail.py new file mode 100644 index 0000000..fc20339 --- /dev/null +++ b/slackmail.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# Copyright 2015 (c) Anna Schumaker. +from urllib import request + + +# TODO: Move the token file outside of code directory +TOKEN = "" +with open("token") as f: + TOKEN = f.read().strip() + + +def call_method(method, args = dict()): + arglist = [] + for (key, value) in args.items(): + arglist += ["%s=%s" % (key, value)] + argstr = "&&".join(arglist) + + server = "https://slack.com/api/" + with request.urlopen("%s/%s?%s" % (server, method, argstr)) as f: + print(f.read().decode()) + + +def call_method_auth(method, args = dict()): + args['token'] = TOKEN + call_method(method, args) + +call_method("api.test") +call_method_auth("auth.test") +