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 <Anna@OcarinaProject.net>
This commit is contained in:
commit
13050a1486
|
@ -0,0 +1,2 @@
|
||||||
|
token
|
||||||
|
*.sw*
|
|
@ -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")
|
||||||
|
|
Loading…
Reference in New Issue