钉钉自定义机器人

来源:互联网 发布:c语言基础代码大全 编辑:程序博客网 时间:2024/06/09 17:16

1.在钉钉里面添加自定义机器人
2.获取https连接以及token

import json,urllib2,timedef dd():    url='https://oapi.dingtalk.com/robot/send?access_token=XXXXXX'    con={"msgtype":"text","text":{"content":"Hello from PYTHON !!!"}}    jd=json.dumps(con)    req=urllib2.Request(url,jd)    req.add_header('Content-Type', 'application/json')    response=urllib2.urlopen(req)    print response,time.ctime() if __name__ == '__main__':    dd()

备注:Python 2.7.13