go-go

微信公众号第三方验证的代码实现

<?php

//获得参数 signature nonce token timestamp echostr
$nonce = $_GET[\'nonce\'];
$token = \'imooc\';
$timestamp = $_GET[\'timestamp\'];
$echostr = $_GET[\'echostr\'];
$signature = $_GET[\'signature\'];
//形成数组,然后按字典序排序
$array = array();
$array = array($nonce, $timestamp, $token);
sort($array);
//拼接成字符串,sha1加密 ,然后与signature进行校验
$str = sha1( implode( $array ) );
if( $str == $signature && $echostr ){
//第一次接入weixin api接口的时候
echo $echostr;
exit;
}

发表于 2016-03-11 16:48  gogo仙人掌  阅读(367)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-10-29
  • 2021-10-19
  • 2021-04-16
  • 2021-11-02
  • 2021-10-17
  • 2021-10-27
  • 2021-11-11
猜你喜欢
  • 2021-10-17
  • 2021-11-08
  • 2021-10-17
  • 2021-12-09
  • 2021-11-04
  • 2021-12-22
  • 2021-12-22
相关资源
相似解决方案