运维脚本集
定时备份脚本
查看进程OOM分数
程序自动拉起
API调用-Shell
Python调用
Golang调用
K8S镜像下载
本文档使用MrDoc发布
返回首页
-
+
Python调用
2023年6月4日 14:15
admin
# -*- coding: UTF-8 -*- import json import requests import hashlib import time import urllib import base64 import sys Sid = "d1b1bd01c5e4b2942536dfd201e603bc" Token = "e17ae7cd8d703adbba60cade50512707" timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime()) shorttime = str(int(time.time()))+"001" STR = Sid+Token+timestamp print(STR) shastr = hashlib.sha1(STR.encode('utf-8')).hexdigest() baststr = str(Sid+":"+timestamp) print(baststr) auths=base64.b64encode(baststr.encode()) url = "https://api.139130.com:9999/api/v1.0.0/voice/notify?sig=" + shastr header = { "Content-Type": "application/json;charset=utf-8", "Authorization": auths, "Accept": "application/json" } #构建请求数据,post请求 data = { "info": { "appID": "f3018ce6608e3e8431e0e4fc99cadb49" }, "subject": { "called": "15914345859", "calledDisplay":"10037", "templateID":"25828", "params": ['测试服务器'], "playTime": 2, "playDelay": 3000, }, "data":"abc123", "timestamp": shorttime } # 对请求的数据进行json封装 sendData = json.dumps(data) sendData = sendData.encode("utf-8") #发送请求 request = requests.post(url=url,headers=header,data=sendData) #打印请求结果 print(request.text)
分享到: