How to realize the automatic reply of text message developed by Wechat official account by php
This article mainly shows you "php how to achieve Wechat official account development of text messages automatic reply", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve Wechat official account development text message automatic reply" this article.
The details are as follows
Download 1.PHP sample code
Download address 1: http://xiazai.jb51.net/201608/yuanma/phpwx(jb51.net).rar
Download address 2: https://mp.weixin.qq.com/wiki/home/index.html (start development-"access Guide -" PHP sample code download)
2.wx_sample.php initial code
3. Call the reply message method
Comment out $wechatObj- > valid () in the wx_sample.php file, and add the sentence "$wechatObj- > responseMsg ();" under it.
4. Keyword automatic reply and follow reply
Keyword stores text messages sent by users on Wechat.
Official developer documentation: https://mp.weixin.qq.com/wiki/home/index.html (message Management-"receive messages-receive event push -" 1. Follow / unfollow events)
There are two differences between following events and normal text messages, one is that the MsgType value is event, and the other is that the event value is subscribe. Since the official documentation (the original wx_sample.php) did not extract this parameter, we need to extract it ourselves. Add two variables $msgType and $event to the program.