###钉钉机器人实例
#!/usr/bin/env python

-- coding:utf-8 --

import urllib2
import json

class DingDing(object):
def init(self):
self.url = ‘https://oapi.dingtalk.com/robot/send?access_token=0192ec88a09f0f5b3545df3e2e70ef93ab563738861d7c79191fb75e608bd41a’
#夏正炜机器人链接
self.headers = {‘Content-Type’: “application/json; charset=utf-8”, ‘User-Agent’:
‘Mozilla/5.0 (Windows; U;Windows NT 6.1; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6’}

def http_post(self):
    data_json = {"msgtype": "text",
                 "text": {"content": " 小夏 ?, 陈美什么时候回家 @15700091446"},
                 "at": {"atMobiles": ["17671653115", "15700091446"]}}
    jdata = json.dumps(data_json)
    req = urllib2.Request(self.url, jdata, self.headers)
    response = urllib2.urlopen(req)
    return response.read()

if name == “main”:
dingding = DingDing()
resp = dingding.http_post()

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐