import http.lib
import json
conn = httplib.HTTPConnection("localhost:8080")
headers = {"Content-type":"application/json"} #application/x-www-form-urlencoded
params = ({"bindHyCardInfo":{"mobileNo":"1881026xxxx","userId":"2","cardno":"7926279367963021","cardpasswd":"xxxxxxxxxxxxxxx","ip":"127.0.0.1"},"header":{"version":"1.0.1","from":"1000","to":"2000","tid":"7926279367963021","time":"12312","token":"SEW342WEER2342","ext":""}})
conn.request("POST", "/core-oper/rest/bindCard", json.JSONEncoder().encode(params), headers)
response = conn.getresponse()
data = response.read()
if response.status == 200:
print ('success')
print (data)
else:
print ('fail')
conn.close()
ä½ ççè¿è¡ä¸è¡
太æè°¢äºï¼è¿è½å麻ç¦æ¨ä¸ä¸ä¹ï¼
æçhttp headæ¯è¿æ ·ç
请æ±HTTP HEADï¼
Authorization:Basic base64.encoding(appKey:appSecret)
Accept :application/json
Content-Type:application/json;charset=UTF-8
å¦ä½æç
§æçhead对å代ç è¿è¡ä¿®æ¹å¢ï¼
æ¹è¿é
params = ({"bindHyCardInfo":{"mobileNo":"1881026xxxx","userId":"2","cardno":"7926279367963021","cardpasswd":"xxxxxxxxxxxxxxx","ip":"127.0.0.1"},"header":{"version":"1.0.1","from":"1000","to":"2000","tid":"7926279367963021","time":"12312","token":"SEW342WEER2342","ext":"", "Authorization":"Basic base64.encoding(appKey:appSecret)","Accept":"application/json","Content-Type":"application/json;charset=UTF-8"}})
ä½ ççè¡ä¸è¡å§