Blogger Information
Blog 7
fans 0
comment 0
visits 7738
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
验证微信公众号开发者服务器配置
沅有芷兮澧有兰
Original
1391 people have browsed it

自己的微信公众号开通很久了,很久都没动过,每年都是到腾讯发邮件告诉我一年没登录过了,要我登录。

最近又要我登录一次,索性就再来玩一玩微信公众号。

之前在开启开发者模式的时候,是直接在服务器上echo $_GET['echostr'];通过验证。

今天就想着把验签自己做一下,代码如下:

<?php
/**
	URL参数	描述
	signature	微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
	timestamp	时间戳
	nonce		随机数
	echostr		随机字符串
*/
$myfile = fopen("wx.txt", "w") or die("Unable to open file!");
$txt = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
fwrite($myfile, $txt);
fclose($myfile);
//'signature=5eb25082bada75ebf2d0067732acacccb6efae07&echostr=3422932780626997117&timestamp=1560765245&nonce=925140347';
$get_timeStamp = $_GET['timestamp'];
$get_nonce = $_GET['nonce'];
$get_echostr = $_GET['echostr'];
$get_signature = $_GET['signature'];
$token = '123abc';

$arr = [$get_timeStamp,$get_nonce,$token];
sort($arr,SORT_STRING);
$my_signature = sha1(implode('',$arr));
if ($my_signature == $get_signature) {
	echo $get_echostr;
}else{
	die('匹配失败!');
}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post