Poodletooth-iLand/toontown/toonbase/ToontownStartRemoteDB.py

31 lines
937 B
Python
Raw Normal View History

2015-07-08 07:15:51 -05:00
import json
import os
import requests
from panda3d.core import *
username = os.environ['ttsUsername']
password = os.environ['ttsPassword']
accountServerEndpoint = 'http://www.toontownstride.com/api/'
session = requests.Session()
csrf_query = session.get(accountServerEndpoint + 'login/')
csrf = session.cookies.get_dict().get('csrftoken', '')
request = session.post(
accountServerEndpoint + 'login/',
data={'username': username, 'password': password, 'csrfmiddlewaretoken': csrf})
try:
response = json.loads('{'+request.text.split('{', 1)[1]) # so that we ignore the csrf token
except ValueError:
print "Couldn't verify account credentials."
else:
if response['status'] != 7:
print response['message']
else:
os.environ['TTS_PLAYCOOKIE'] = response['token']
os.environ['TTS_GAMESERVER'] = response['gameserver']
# Start the game:
import toontown.toonbase.ToontownStart