Home > Article > WeChat Applet > WeChat enterprise account development: Turn on callback mode/Python judgment information-reply to specified content sample code
1 The steps to register a WeChat business account are omitted. Very simple.
Select the application center below, Enterprise Assistant, and select callback mode.
Choose to randomly generate token AESKEY. Address Enter your server address.
Select Settings, create a new management group, and then you can see the COPID and Secret
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()
python main.py ##运行测试了。。。。
修改端口号:itchatmp.run(port=8888) 记得修改防火墙,这里我就被坑了。 微信回调模式支持 x.x.x.x:8888 iptable -A INPUT -p tcp -m tcp --dport 8888 -j ACCEPT
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!