作者:邓聪聪
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import sys
import json
import datetime
import requests
txt=open('/tmp/message.txt','r') #打开文本
msg=txt.read() #读取文本内容
def info():
url = 'https://oapi.dingtalk.com/robot/send?access_token=d3a692f22fe98e825307e5df64bbff4b2d4d69b162a96decb9532077a0316524'
headers = {
'Content-Type': 'application/json;charset=utf-8'
}
formdata = {
"msgtype": "text",
"text": {"content":str(msg)}
}
hhh = requests.post(url=url, data=json.dumps(formdata), headers=headers)
print hhh.text
if __name__ == '__main__':
info()
txt.close() #关闭文本