工具&利器

微信公众平台之接口列表及作用说明

1.菜单点击及关键字回复消息接口

https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token= TOKEN

消息先发送到微信平台,然后微信平台给服务作出响应 到我们(微信公众平台后台里的那个) 接口配置信息 中的 URL地址中

官方说明 link 

2.接口验证代码

这段验证代码最好写在站点入口处

if (! empty ( $_GET ['echostr'] ) && ! empty ( $_GET ["signature"] ) && ! empty ( $_GET ["nonce"] )) {
	$signature = $_GET ["signature"];
	$timestamp = $_GET ["timestamp"];
	$nonce = $_GET ["nonce"];
	
	$tmpArr = array (
			SYSTEM_TOKEN, //token 定义的常量
			$timestamp,
			$nonce 
	);
	sort ( $tmpArr, SORT_STRING );
        
	$tmpStr = sha1 ( implode ( $tmpArr ) );
	if ($tmpStr == $signature) {
		echo $_GET ["echostr"];
	}
	exit ();
}

 

发表评论