好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > php微信開發之關注事件

php微信開發之關注事件

熱門標簽:沈陽人工智能電銷機器人公司 合肥外呼系統app 寶安400電話辦理 h5 地圖標注 哈爾濱400電話辦理到易號網 拉薩打電話機器人 智能外呼電銷系統 電銷機器人-快迭智能 高識別電銷機器人

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

?php
/**
 * wechat php test
 */

//define your token
define("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;
  }
 }
}

?>

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

您可能感興趣的文章:
  • php判斷用戶是否關注微信公眾號
  • 微信公眾號判斷用戶是否已關注php代碼解析
  • php微信公眾號開發之歡迎老朋友

標簽:威海 巴中 梅州 山東 林芝 張家口 成都 泰州

巨人網絡通訊聲明:本文標題《php微信開發之關注事件》,本文關鍵詞  php,微信,開,發之,關注,事件,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《php微信開發之關注事件》相關的同類信息!
  • 本頁收集關于php微信開發之關注事件的相關信息資訊供網民參考!
  • 推薦文章