微信公众平台SDK Python
2024-08-24 14:56:41
微信公众平台SDK
项目背景
从2014年开始玩微信公众平台,试用过其中大多数的功能,如:消息回复、自定义菜单、公众号中的支付,页面授权等。之前的程序中都是直接调用公众平台的接口,这样复用功能无法实现。现将功能独立出单独模块
目前完成
- 获取access_token方法
- 获取微信服务器IP地址
- 自定义菜单中的查询、创建、删除(不包括个性化菜单接口)
- 消息管理中的接收普通消息、接收事件推送
- 消息管理中的被动回复用户消息
- 添加tornado代码的demo实例
使用示例
获取access_token方法
from wechat.base import get_access_token_dict get_access_token_dict(APPID, APPSECRET)
消息处理基类
继承基础的消息处理类BaseHandler, 重写对应方法即可。 如文本、图片、视频等对应的处理方法分别问on_text、on_image、on_video。
from wechat.message import * class MessageHandler(BaseHandler): def on_text(self, xml_dict): from_user = xml_dict['FromUserName'] to_user = xml_dict['ToUserName'] create_time = xml_dict['CreateTime'] content = xml_dict['Content'] text_response = TextResponse(from_user=from_user, to_user=to_user, create_time=create_time, content=content) return text_response
自定义菜单接口
from wechat.menu.client import Client client = Client(access_token['access_token']) # 创建菜单 client.create_menu(data) # 获取菜单 client.get_menu() # 删除菜单 client.delete_menu()
下一步计划
- 继续补充其他常用接口
感兴趣的同学可以加入到项目中一起完善
github: https://github.com/lyroge/wechat_sdk
最新文章
- .NET 实现并行的几种方式(三)
- Windows下使用VisualSVN Server搭建SVN服务器
- Opencv出现错误“0xc000007b”的解决办法
- linux下source命令的基本功能
- hdu 3172 Virtual Friends
- IDispatch接口介绍
- tail tailf 使用
- 使用NFS安装oracle软件
- Rosenblatt感知器
- linux中的两个命令setfacl和chmod有什么区别
- C语言面试题分类->;宏定义
- C#自动化操作IE浏览器系列之一打开新的浏览器并导航到百度进行搜索
- react 在 componentWillMount() 中调用异步函数时,componentWillMount() finishes after render()
- 【Java】 剑指offer(53-3) 数组中数值和下标相等的元素
- Windows 10 Install rabbitmq-server-3.6.9
- nginx 下载 大文件被截断
- java 浮点运算
- Java设计模式之七大结构型模式(附实例和详解)
- Python requests 使用心得
- IDEA里点击Build,再Build Artifacts没反应,灰色的?解决办法(图文详解)
热门文章
- 一点一滴之NHibernate
- [LeetCode] Longest Valid Parentheses 动态规划
- HTML5大数据可视化效果(二)可交互地铁线路图
- 【转】How to resolve ORA-19706 error when select from dblink
- div 等高
- 【PRML读书笔记-Chapter1-Introduction】1.1 Example:Polynomial Curve Fitting
- JS对象的几个方法介绍
- [python]初探socket
- HT图形组件设计之道(三)
- [SQL] Oracle基础语法