#coding=utf-8
import json
import requests
# based url and required header
url = "http://192.168.1.12/zabbix/api_jsonrpc.php"
header = {"Content-Type":"application/json"}
# auth user and password
data = {
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "Admin",
"password": "zabbix"
},
"id":1,
"auth":None
}
r = requests.post(url,headers=header,data=json.dumps(data))
print r.status_code
print r.content
print json.loads(r.content)['result']
取得相应token值