推送文本类消息:
def __push_to_wechat(self, content): """ 文本类消息推送至企业微信 :return: """ data = { "touser": "XXXXXXX", #"toparty": '3', # "totag": "TagID1 | TagID2", "msgtype": "text", "agentid": 1000002, "text": { "content": content }, "safe": 1 } '''''' try: curl = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}'.format( token=self.__get_token()) res = self.__http_request.post(curl, data) self.__check_push_result(res['errcode']) except Exception: self.__logger.error("消息推送失败,请检查网络连接.")
推送临时图片类消息:
#获取图片的media_id def get_media_id(self): gurl = "https://qyapi.weixin.qq.com/