Home > WeChat Applet > WeChat Development > WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code

WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code

高洛峰
Release: 2017-03-22 15:45:35
Original
2806 people have browsed it

1 The steps to register a WeChat business account are omitted. Very simple.

Select the application center below, Enterprise Assistant, and select callback mode.

WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code

Choose to randomly generate token AESKEY. Address Enter your server address.

WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code

Select Settings, create a new management group, and then you can see the COPID and Secret

WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code

Change the above 4 Parameters are written to the file below.

python3 -m pip  install  itchatmp    ###python3安装模块  
 
具体可百度itchatmp官方文档
 
 
 
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()
Copy after login
python  main.py  ##运行测试了。。。。
Copy after login
修改端口号:itchatmp.run(port=8888)
 
记得修改防火墙,这里我就被坑了。  微信回调模式支持  x.x.x.x:8888
 
iptable   -A INPUT -p tcp -m tcp --dport 8888 -j ACCEPT
Copy after login

Result:

When a WeChat enterprise account is received, the reply He Quan is returned Name: He Quan

The above is the detailed content of WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template