Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement the verification of WeChat Mini Programs message push php server

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to implement WeChat Mini Programs message push php server verification". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Detailed explanation of WeChat Mini Programs message push php server verification example

Wechat document (there is a "access guide" below): https://mp.weixin.qq.com/debug/wxadoc/dev/api/custommsg/callback_help.html

Settings page (Settings > Development Settings):

Https://mp.weixin.qq.com/wxopen/initprofile?action=home&lang=zh_CN

1. Set server domain name

For example: https://hosts.com

Note the difference between http and https protocols.

two。 Set up message push

2.1 adding server interface test.php,test.php to your server mainly verifies whether the message is sent by Wechat through token. The code refers to the official example:

Define ("TOKEN", "xxxxx"); / token$wechatObj = new wechatAPI () filled in at backend; $wechatObj- > isValid (); class wechatAPI {public function isValid () / / verify Wechat API. If confirmed as Wechat, return its echostr parameter {$echoStr = $_ GET ["echostr"]; if ($this- > checkSignature ()) {echo $echoStr; exit;}} private function checkSignature () / / official verification function {$signature = $_ GET ["signature"] $timestamp = $GET ["timestamp"]; $nonce = $_ GET ["nonce"]; $token = TOKEN; $tmpArr = array ($token, $timestamp, $nonce); sort ($tmpArr, SORT_STRING); $tmpStr = implode ($tmpArr); $tmpStr = sha1 ($tmpStr); if ($tmpStr = = $signature) {return true;} else {return false;}

2.2 set Mini Program background message push related information

URL (server address): https://hosts.com/xx/test.php

Token: any string that conforms to the specification, such as "xxxxx" defined above

EncodingAESKey (message encryption key): (randomly generated, just save it yourself, this encryption and decryption only)

Message encryption: choose plaintext for the time being, without thinking about encryption and decryption.

Data format: choose according to the demand.

Submit, if there is no problem, it will be successful. (if there is a problem, you can pass the browser test with fake data.)

This is the end of the content of "how to implement WeChat Mini Programs message push php server authentication". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report