search
HomeWeChat AppletWeChat DevelopmentWeChat 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.

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()
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!

Statement
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)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.