微信文档中开放的接口只有被动回复用户的消息。但是看到很多平台却能主动发送消息,请问是怎么样做的?谁能简单分享一个code sample吗?
如果没有Java的话,其他语言也可以。谢谢
伊谢尔伦2017-04-17 12:59:37
1. If the user interacts with the official account within 48 hours, such as sending a message or clicking on the menu, then the user can proactively send customer service messages within 48 hours.
http://mp.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E5%AE%A2%E6%9C%8D%E6% B6%88%E6%81%AF
2. Advanced (certified) service accounts can apply for template messages. Template messages are message types with a certain template and can be sent at any time.
PHPz2017-04-17 12:59:37
Proactively sending messages can currently be achieved in two ways:
The first one: Use WeChat’s advanced group sending interface and customer service interface (can only be used after authentication). The server has 4 subscription accounts per month and one per day. The customer service interface can send messages to individual users but must be This user has interacted with the public account within 24 hours.
The second type of simulated login obtains the fakeid of the following user and simulates sending messages through the fakeid (it may be blocked by TX, use with caution). The rules are the same. The user has interacted with the official account within 24 hours.
阿神2017-04-17 12:59:37
Not all public accounts can actively send messages, and there is no relevant API
巴扎黑2017-04-17 12:59:37
Official accounts are divided into subscription accounts and service accounts. Subscription accounts can actively push one message to users every day, while service accounts can only actively push one message every month. You can find this regulation on the WeChat public platform.
Others require users to actively send information to the official account, and the official account can actively reply to the user's information within a certain period of time.
That’s pretty much what I understand~
伊谢尔伦2017-04-17 12:59:37
Use the customer service sending function. Passive response information has great limitations. By default, the WeChat server will re-initiate the request three times if it does not respond within 5 seconds. So at this time, customer service information is used to send, but this function requires WeChat official account authentication.
PHP中文网2017-04-17 12:59:37
If you have a WeChat-certified account, it is recommended to use the official method. If you only have the most basic receiving function, you can try using HTTPclient to simulate a browser login to send messages, but you still have to ensure that there is interaction within 48 hours. First use a packet capturer to capture a few packets, and then use httpclient to simulate the parameters and address of the po packet, and you will get a corresponding reply.
迷茫2017-04-17 12:59:37
Simulate login and obtain the fakeid of the interactor. Then you can directly simulate sending messages in the WeChat background. It seems that an interaction has a validity period of 5 days, which is the same as the validity period of reply messages in the WeChat background.