Forum:Please tell me why this bot isn't working

Lieutenant S., Geschichtsmeister des Lexipedium (talk) 15:03, 18 August 2014 (BST)

post_request = {"action":"query","prop":"info|revisions","intoken":"edit","titles":"Encyclopedia Muricana:Sandbox","format":"json"} req = requests.post("http://encyclopediamuricana.us/w/api.php", data=post_request, cookies=cookies) r_json = json.dumps(req.json) r_json = json.loads(r_json) cookies = req.cookies
 * Editing part of the script:
 * 1) Getting an edit token

print req.json

edittoken = r_json[u"query"][u"pages"][u"-1"][u"edittoken"] edittoken = str(edittoken) edittoken = urllib.quote_plus(edittoken) print edittoken
 * 1) edittoken = edittoken.replace("+\\","")

edittext = "Bot edit" edittext = urllib.quote_plus(edittext) post_request = {"format":"json","action":"edit","title":"Encyclopedia Muricana:Sandbox","appendtext":edittext,"token":edittoken} headers = {"Content-Type":"application/x-www-form-urlencoded"} req = requests.post("http://encyclopediamuricana.us/w/api.php", headers=headers, data=post_request, cookies=cookies) print req.json {u'servedby': u'prod4', u'error': {u'info': u'Invalid token', u'code': u'badtoken'}}
 * 1) Making an edit
 * Error:

Lieutenant S., Geschichtsmeister des Lexipedium (talk) 15:03, 18 August 2014 (BST)