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

主頁 > 知識庫 > php微信開發之圖片回復功能

php微信開發之圖片回復功能

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

本文實例為大家分享了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;
        $customrevent = $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 = "33333333333";
          $msgType = "text";
          $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
          echo $resultStr;
          }  
        if($type=="image" ){
          $contentStr = "你的圖片很棒!";
          $msgType = "text";
          $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
          echo $resultStr;
          }  

        if(!empty( $keyword ))
        {                
          $msgType = "text";
          if($keyword=="1"){
          $contentStr = "333";}
          if($keyword=="2"){
          $contentStr = "444
          if($keyword=="3"){
          $contentStr = "11";}          
          $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微信公眾號開發(4)php實現自定義關鍵字回復
  • php版微信開發之接收消息,自動判斷及回復相應消息的方法
  • php版微信公眾平臺回復中文出現亂碼問題的解決方法
  • 微信公眾號開發之文本消息自動回復php代碼
  • 驗證token、回復圖文\文本、推送消息的實用微信類php代碼
  • PHP微信開發之模板消息回復
  • PHP微信開發之文本自動回復
  • PHP微信開發之微信消息自動回復下所遇到的坑

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

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