zabbix--python短信接口脚本

2023-01-31 01:01:16 zabbix

#!/usr/bin/env python
#-- coding: utf8 --

import sys
import requests
import JSON

def sendsms(phone, subject, message):
"""
发送短信
"""
values = {"appCode": "ZBXSZ",
"businessType": "tz",
"businessNo": "adf324",
"phoneNums": phone,
"templCode": "bqjrtzZBXSZyzryy73760",
"atTime": "null",
"paramsBody": {
"value0": subject,
"value1": message
}
}
headers = {'Content-Type': 'application/json'}

host = 'aps.bqjr.cn'
post_url = 'Http://' + host + '/bqjr/msg/send'
response = requests.post(url=post_url, headers=headers, data=json.dumps(values))
try:
    req= requests.post(url=post_url, data=json.dumps(values))
    print req.content
except Exception, e:
    print e

if name == 'main':
phone = sys.argv[1]
subject = sys.argv[2]
message = sys.argv[3]
sendsms(phone, subject, message)

相关文章