惜风不起、唯有努力!
python发送消息给钉钉

python发送消息给钉钉

源代码

#!/usr/bin/python

import requests
import json
import sys

headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx"

def msg(text):
    json_text= {
     "msgtype": "text",
        "text": {
            "content" : text
        },
        "at": {
            "atMobiles": [
                ""
            ],
            "isAtAll": True
        }
    }
    print(requests.post(api_url,json.dumps(json_text),headers=headers).content)

if __name__ == '__main__':
    text = sys.argv[1]
    msg(text)

发表回复

您的电子邮箱地址不会被公开。