python client使用http post 到server端的代码
代码如下:
import urllib, httplib import utils import json class User: def __init__(self): print 'a' def login(self, imsi, ua): print "==============user start login==================" input = { "method" : "user.login", "userName" : "", "userPass" : "", } input["sig"] = utils.getSignature(input) params = urllib.urlencode(input) headers = { "user-agent" : ua, "Appstore-clientType" : "android", "Appstore-IMEI" : "123456789000000", "Appstore-IMSI" : imsi } try: connection = httplib.HTTPConnection(utils.API_HOST) connection.request("POST", "/api", params, headers) response = connection.getresponse().read() #print "=========" + response connection.close() except Exception, e : print "========" + str(e) if "errorcode" in response or response is None: return results = json.loads(response) return results["results"].encode("utf-8")
相关推荐
olyqcool 2020-04-26
Guanjs0 2020-11-09
wmsjlihuan 2020-09-15
shishengsoft 2020-09-15
poplpsure 2020-08-17
CyborgLin 2020-08-15
Richardxx 2020-07-26
sunnyhappy0 2020-07-26
knightwatch 2020-07-19
wcqwcq 2020-07-04
chichichi0 2020-06-16
YAruli 2020-06-13
JF0 2020-06-13
84423067 2020-06-12
心丨悦 2020-06-11
zkwgpp 2020-06-04
stoneechogx 2020-06-04
litterfrog 2020-05-30