源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

python client使用http post 到server端的代码

  • 时间:2022-02-22 05:09 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:python client使用http post 到server端的代码
[u]复制代码[/u] 代码如下:
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")
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部