def CheckIsLogin91(self, uid, session): XMHttpClient.set_pro_url(self, xiaomi_conf.Session_URL_91) params = {} params['AppId'] = self.clientId params['Act'] = 4 # 登录的act编号 params['Uin'] = uid params['SessionId'] = session params['Sign'] = self.xmUtils.buildSignature_91(params, self.clientSecret) return self.getErrCode(params)
def CheckIsLoginPP(self, sid): XMHttpClient.set_pro_url(self, xiaomi_conf.Session_URL_PP) params = {} params['id'] = int(time.time()) params['service'] = "account.verifySession" params['data'] = {'sid': sid} params['game'] = {'gameId': int(self.clientId)} params['encrypt'] = "md5" params['sign'] = self.xmUtils.buildSignature_PP(sid, self.clientSecret) print "params::", params return self.postErrCode(params)
def __init__(self, clientId, accessToken): XMHttpClient.__init__(self, xiaomi_conf.API_URL) self.clientId = clientId self.accessToken = accessToken self.xmUtils = XMUtils() self.host = urlparse(xiaomi_conf.API_URL).hostname
def getErrCode(self, params): res = XMHttpClient.get(self, '', params) data = res.read() jsonObject = XMHttpClient.safeJsonLoad(self, data) return jsonObject
def getAccessToken(self, params): res = XMHttpClient.get(self, self.OAUTH2_PATH['token'], params) jsonObject = XMHttpClient.safeJsonLoad(self, res.read()) return jsonObject
def __init__(self, clientId, clientSecret, redirectUri): XMHttpClient.__init__(self, xiaomi_conf.VerifySession_URL) self.clientId = clientId self.clientSecret = clientSecret self.redirectUri = redirectUri self.xmUtils = XMUtils()
def postErrCode(self, params): res = XMHttpClient.post(self, '', params, header={'content-type':'text/plain'}) jsonObject = XMHttpClient.safeJsonLoad(self, res.read(),) return jsonObject
def CheckIsLoginAS(self, token): XMHttpClient.set_pro_url(self, xiaomi_conf.Session_URL_AS) params = {} params['token'] = token return self.getErrCode(params)
def CheckIsLoginTB(self, session): XMHttpClient.set_pro_url(self, xiaomi_conf.Session_URL_TB) params = {} params['k'] = session return self.getTBCode(params)
def getTBCode(self, params): res = XMHttpClient.get(self, '', params) data = res.read() return data
def __init__(self, clientId, clientSecret, redirectUri): XMHttpClient.__init__(self, xiaomi_conf.OAUTH2_URL) self.clientId = clientId self.clientSecret = clientSecret self.redirectUri = redirectUri