微信企业号:python 利用itchatmp开启回调模式/判断信息--回复指定内容
时间:2017-02-21 19:43:17
收藏:0
阅读:2547
安装
yum install httpd mod_wsgi vim /etc/httpd/conf.d/wsgi.conf <VirtualHost *:80> DocumentRoot /var/www/wsgi WSGIScriptAlias / /var/www/wsgi/webapp.wsgi </VirtualHost> systemctl restart httpd mkdir -p /var/www/wsgi/ cd /var/www/wsgi
设置
vim index.wsgi from main import app app = itchatmp.run(isWsgi=True)
vim config.yaml name: wsgi version: 1 libraries: - name: lxml version: ‘2.3.4‘ - name: PyCrypto version: ‘2.6‘
vim main.py import itchatmp from itchatmp.content import TEXT itchatmp.update_config(itchatmp.WechatConfig( token=‘xxxxxxxxxxxx‘, copId = ‘xxxxxxxxxxxxx‘, appSecret = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx‘, encryptMode=itchatmp.content.SAFE, encodingAesKey=‘xxxxxxxxxxxxxxxxxxxxxxxxxxxx‘,)) i=‘何全‘ @itchatmp.msg_register(itchatmp.content.TEXT) def text_reply(msg): if msg[‘Content‘] == i : msg[‘Content‘] = ‘姓名:{}‘.format(i) return msg[‘Content‘] else: print(23333) itchatmp.run()
python main.py ##运行测试了。。。。
本文出自 “何全” 博客,请务必保留此出处http://hequan.blog.51cto.com/5701886/1899902
评论(0)