Thread:Project:Support desk/How do I get the login token for a Python bot?/reply (3)

I have this now, which is much better, but it still doesn't work.

import requests import json

loginPost = {'action' : 'login', 'lgname' : 'SashaBot', 'lgpassword' : 'xxxxxxxxxxxxxxxxx', 'format' : 'json'} apiLogin = requests.post('http://www.sturmkrieg.us/api.php', params=loginPost)

apiLoginC = apiLogin.content apiLoginJ = json.loads(apiLoginC) apiLoginToken = apiLoginJ['login']['token'] print apiLoginToken

loginPost = {'action' : 'login', 'lgname' : 'SashaBot', 'lgpassword' : 'xxxxxxxxxxxxxxxxxx', 'lgtoken' : str(apiLoginToken), 'format' : 'json'} apiLogin = requests.post('http://www.sturmkrieg.us/api.php', params=loginPost) print apiLogin.content

editGet = {'title' : 'Sandbox', 'prependtext' : 'Hello world!', 'token' : str(apiLoginToken)} apiEdit = requests.get('http://www.sturmkrieg.us/api.php', params=editGet)