-
Notifications
You must be signed in to change notification settings - Fork 1
/
weixin-robot-advanced-api.php
50 lines (43 loc) · 1.15 KB
/
weixin-robot-advanced-api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
//提交认证的时候如果无法通过,可以使用该文件来验证通过。
$use_plugin = 1;
if($use_plugin){
include('../../../wp-load.php');
//file_put_contents(WP_CONTENT_DIR.'/uploads/weixin.log',var_export($_SERVER,true));
$wechatObj = new wechatCallback();
$wechatObj->valid();
exit;
}else{
define ( "TOKEN", "weixin" );
class wechatCallbackapiTest{
public function valid()
{
$echoStr = $_GET["echostr"]; //随机字符串
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
private function checkSignature() {
$signature = $_GET ["signature"];
$timestamp = $_GET ["timestamp"];
$nonce = $_GET ["nonce"];
$token = TOKEN;
$tmpArr = array (
$token,
$timestamp,
$nonce
);
sort ( $tmpArr );
$tmpStr = implode ( $tmpArr );
$tmpStr = sha1 ( $tmpStr );
if ($tmpStr == $signature) {
return true;
} else {
return false;
}
}
}
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
}