国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php微信開發之關注事件

2024-05-05 00:04:12
字體:
來源:轉載
供稿:網友

本文實例為大家分享了php微信關注事件的具體代碼,供大家參考,具體內容如下

<?php/** * wechat php test *///define your tokendefine("TOKEN", "weixin");$wechatObj = new wechatCallbackapiTest();//$wechatObj->valid();$wechatObj->responseMsg();class wechatCallbackapiTest{  public function valid()  {    $echoStr = $_GET["echostr"];    //valid signature , option    if($this->checkSignature()){      echo $echoStr;      exit;    }  }  public function responseMsg()  {    //get post data, May be due to the different environments    $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];    //extract post data    if (!empty($postStr)){        $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);        $fromUsername = $postObj->FromUserName;        $toUsername = $postObj->ToUserName;        $type = $postObj->MsgType;        $customevent = $postObj->Event;        $keyword = trim($postObj->Content);        $time = time();        $textTpl = "<xml>              <ToUserName><![CDATA[%s]]></ToUserName>              <FromUserName><![CDATA[%s]]></FromUserName>              <CreateTime>%s</CreateTime>              <MsgType><![CDATA[%s]]></MsgType>              <Content><![CDATA[%s]]></Content>              <FuncFlag>0</FuncFlag>              </xml>";               if($type=="event" and $customrevent=="subscribe"){          $contentStr = "感謝你的關注/n回復1查看聯系方式/n回復2查看最新資訊/n回復3查看法律文書";          $msgType = "text";          $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);          echo $resultStr;          }          if(!empty( $keyword ))        {                          $msgType = "text";          if($keyword=="1"){          $contentStr = "qiphon";}          if($keyword=="2"){          $contentStr = "test 。";}          if($keyword=="3"){          $contentStr = "test333";}                   $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);          echo $resultStr;        }else{          echo "Input something...";        }    }else {      echo "";      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;    }  }}?>

 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 长顺县| 三台县| 临安市| 大庆市| 建昌县| 若尔盖县| 多伦县| 山阳县| 延庆县| 江阴市| 新密市| 松溪县| 安陆市| 武冈市| 蒲江县| 南陵县| 房山区| 长葛市| 赣州市| 曲靖市| 汾阳市| 思茅市| 三河市| 武城县| 枣阳市| 县级市| 丘北县| 云阳县| 平昌县| 商城县| 镇赉县| 右玉县| 冀州市| 邵阳市| 科技| 英山县| 湘潭县| 梅州市| 清涧县| 嘉义县| 嘉义县|