#!/usr/bin/env python

-- coding:utf-8 --

import urllib2
import json

class DingDing(object):
def init(self):
self.url = #钉钉机器人链接
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, info):
    data_json = {"msgtype": "text",
                 "text": {"content": " 亲 %s @176xxxx3115" % info},
                 "at": {"atMobiles": ["176xxxx3115"]}}
    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()
info = ‘没有@到创建人员’
resp = dingding.http_post(info)

Logo

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

更多推荐