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

Mar 22, 2017 pm 03:45 PM

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)