python client使用http post 到server端的代碼
更新時間:2013年02月10日 17:44:24 作者:
python client使用 http post 到server端的代碼,供大家學(xué)習(xí)參考
復(fù)制代碼 代碼如下:
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")
您可能感興趣的文章:
- PHP中soap用法示例【SoapServer服務(wù)端與SoapClient客戶端編寫】
- Java虛擬機JVM之server模式與client模式的區(qū)別
- Python Socket實現(xiàn)簡單TCP Server/client功能示例
- Android系統(tǒng)進程間通信(IPC)機制Binder中的Server和Client獲得Service Manager接口之路
- python實現(xiàn)的udp協(xié)議Server和Client代碼實例
- SQL Server Native Client下載 SQL Server Native Client安裝方法
- 使用Java實現(xiàn)簡單的server/client回顯功能的方法介紹
- Asp.Net 不同的OnClick事件區(qū)別小結(jié)(onserverclick,onclientclick)
- JVM Client和Server端有什么區(qū)別
相關(guān)文章
python啟動應(yīng)用程序和終止應(yīng)用程序的方法
今天小編就為大家分享一篇python啟動應(yīng)用程序和終止應(yīng)用程序的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06Python的凈值數(shù)據(jù)接口調(diào)用示例分享
這篇文章主要介紹了Python的凈值數(shù)據(jù)接口調(diào)用示例分享的相關(guān)資料,需要的朋友可以參考下2016-03-03linux環(huán)境下安裝python虛擬環(huán)境及注意事項
這篇文章主要介紹了linux環(huán)境下安裝python虛擬環(huán)境,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2020-01-01