欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序url與token設(shè)置詳解

 更新時(shí)間:2017年09月26日 14:59:53   作者:cats6438  
這篇文章主要介紹了微信小程序url與token設(shè)置詳解的相關(guān)資料,希望通過(guò)本文能幫助到大家解決類似問(wèn)題,需要的朋友可以參考下

微信小程序url與token設(shè)置詳解

新浪云應(yīng)用sae的代碼里創(chuàng)建一個(gè)weixin.php文件,寫入以下代碼

define("TOKEN","myToken");// 后臺(tái)填寫的token,在微信公眾平臺(tái)啟用
$wechatObj = new wechatAPI();
$wechatObj->isValid();
class wechatAPI
{
  public function isValid()//驗(yàn)證微信接口,驗(yàn)證函數(shù)以外的代碼和微信公眾號(hào)開發(fā)token設(shè)置相同
  {
     $echoStr = $_GET["echostr"];
     if ($this->checkSignature()) {
       header('content-type:text');//add,一定要加入header
      echo $echoStr;
      exit;
     }
  }
  private function checkSignature()  //官方的驗(yàn)證函數(shù)
  {
     $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;
     }
  }
};

保存后通過(guò)url訪問(wèn),在地址欄復(fù)制url,寫入微信公眾平臺(tái)中

在微信公眾平臺(tái)的開發(fā)設(shè)置中,填入以上獲得的url和設(shè)置的token,自動(dòng)生成EncodingASEKey

設(shè)置完成

如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論