python调用mongodb发送微信企业号
发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,python2.x注意:data变量里, agent_id为刚刚创建的应用id(可在web页面看到)toparty即为目标部门,或者可以用touser,totag指定目标账户比较简单的调用,已实测,可
千家信息网最后更新 2025年02月02日python调用mongodb发送微信企业号
python2.x注意:data变量里, agent_id为刚刚创建的应用id(可在web页面看到)toparty即为目标部门,或者可以用touser,totag指定目标账户比较简单的调用,已实测,可以使用。#coding:utf-8import sysimport requestsimport jsonfrom pymongo import MongoClientreload(sys)sys.setdefaultencoding('utf-8')class Weixin(object): def __init__(self, corp_id, corp_secret): self.token_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s' %(corp_id, corp_secret) self.send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' def get_token(self): try: r = requests.get(self.token_url, timeout=10) except Exception as e: print e sys.exit(1) if r.status_code == requests.codes.ok: data = r.json() if data.get('errcode'): print data['errmsg'] sys.exit(1) return data['access_token'] else: print r.status_code sys.exit(1) def send(self,message): url = self.send_url + self.get_token() data = { "touser": "hequan2011", "msgtype": "text", "agentid": "0", "text": { "content": message }, "safe":"0" } send_data = json.dumps(data,ensure_ascii=False) try: r = requests.post(url, send_data) except Exception, e: print e sys.exit(1) if r.status_code == requests.codes.ok: print r.json() else: print r.code sys.exit(1) corpid = 'xxxxxxxxxxx'corpsecret = 'xxxxxxxxxxxxxxxxx'client = MongoClient('mongodb://user:password@127.0.0.1:27017/')db = client.kucollection = db.biaoa = []for data in collection.find(): a.append(data)l = a[0]g = lz = str(g["name"])z1 = int(g["jg"])print zmsg = "1:{0}\n 2:{1}\n".format(z,z1)w = Weixin(corpid,corpsecret)w.send(msg)
目标
变量
可在
账户
部门
页面
实测
应用
企业
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
服务器的netbios
售后好的零信任架构网络安全
在学生信息数据库管理
计算机网络技术中经济可行性
端游连接不上服务器什么情况
传奇最全数据库下载
我的世界服务器自助充值插件
redis数据库同步
邯郸安卓软件开发价格
linux nat服务器
网络安全大会新闻
大同口碑好的网络安全服务保障
学软件开发西安市
关于网络安全的博客英语作文
qvod资源服务器怎么绑定域名
浙江常见软件开发性价比
linux查看服务器是几c
农资数据库软件
pdsoft导入数据库失败
山西电视墙服务器
学软件开发哪里学
锐思数据库的波动率
上海安永网络安全咨询招聘
合肥服务器机柜批发
公司内部网络安全文件
服务器防火墙安装位置
上海上门软件开发答疑解惑
msyql数据库大全
网络技术科技
全民奇迹服务器数据库名字