微信公众平台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() 


下一步计划

  1. 继续补充其他常用接口

感兴趣的同学可以加入到项目中一起完善

github: https://github.com/lyroge/wechat_sdk

最新文章

  1. .NET 实现并行的几种方式(三)
  2. Windows下使用VisualSVN Server搭建SVN服务器
  3. Opencv出现错误“0xc000007b”的解决办法
  4. linux下source命令的基本功能
  5. hdu 3172 Virtual Friends
  6. IDispatch接口介绍
  7. tail tailf 使用
  8. 使用NFS安装oracle软件
  9. Rosenblatt感知器
  10. linux中的两个命令setfacl和chmod有什么区别
  11. C语言面试题分类->宏定义
  12. C#自动化操作IE浏览器系列之一打开新的浏览器并导航到百度进行搜索
  13. react 在 componentWillMount() 中调用异步函数时,componentWillMount() finishes after render()
  14. 【Java】 剑指offer(53-3) 数组中数值和下标相等的元素
  15. Windows 10 Install rabbitmq-server-3.6.9
  16. nginx 下载 大文件被截断
  17. java 浮点运算
  18. Java设计模式之七大结构型模式(附实例和详解)
  19. Python requests 使用心得
  20. IDEA里点击Build,再Build Artifacts没反应,灰色的?解决办法(图文详解)

热门文章

  1. 一点一滴之NHibernate
  2. [LeetCode] Longest Valid Parentheses 动态规划
  3. HTML5大数据可视化效果(二)可交互地铁线路图
  4. 【转】How to resolve ORA-19706 error when select from dblink
  5. div 等高
  6. 【PRML读书笔记-Chapter1-Introduction】1.1 Example:Polynomial Curve Fitting
  7. JS对象的几个方法介绍
  8. [python]初探socket
  9. HT图形组件设计之道(三)
  10. [SQL] Oracle基础语法