資源簡介
微信自動回復源碼(入門級)
代碼片段和文件信息
//定義TOKEN的參數
define(“TOKEN“?“weixin“);
//實例化一個類
$wechatObj?=?new?wechatCallbackapiTest();
//判斷get過來的數據是否沒有設置
if?(!isset($_GET[‘echostr‘]))?{
//執行相應消息
????$wechatObj->responseMsg();
}else{
//訪問類中的valid方法??驗證簽名
????$wechatObj->valid();
}
class?wechatCallbackapiTest
{
????//驗證簽名
????public?function?valid()
????{
????????$echoStr?=?$_GET[“echostr“];
????????$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){
????????????echo?$echoStr;
????????????exit;
????????}
????}
????//響應消息
????public?func
- 上一篇:凡信2.0服務端 php源碼
- 下一篇:THINKPHP 通用后臺管理系統
評論
共有 條評論