View on GitHub

Wechatpy

Download this project as a .zip file Download this project as a tar.gz file

A python interface to connect wechat public platform


Features


Usage

Put the file into your application folder, then call the interface according to your app framework. Generally, is you get the request XML file you should call the interface like

from wchooker import wcInfoHandler
handler = wcInfoHandler()
responseMsg = handler.respondMsg(rawStr) #rawStr is the raw xml from wechat platform

Then you should modify the file "wcMsgProc.py" as

#------------------processing---------------------------
      if (wcMsg.msgType == MESSAGE_TEXT):#similar in image messages and location messages
      response = wcTextResponse()
      response.resContent = wcMsg.msgContent
      log(wcMsg.msgHost)

      #add yourselves' handling code here
      #please see "wcData.py" for the structure of the class wcMsg
      #The return content should be set to response.resContent
#------------------------------------------------------
      return response