php微信開發(fā)之圖片回復(fù)功能
更新時(shí)間:2018年06月14日 10:17:17 作者:qiphon3650
這篇文章主要為大家詳細(xì)介紹了php微信開發(fā)之圖片回復(fù)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了php微信圖片回復(fù)功能的具體代碼,供大家參考,具體內(nèi)容如下
<?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; } } } ?>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- php微信開發(fā)之音樂回復(fù)功能
- php微信開發(fā)之關(guān)鍵詞回復(fù)功能
- php微信公眾號開發(fā)(4)php實(shí)現(xiàn)自定義關(guān)鍵字回復(fù)
- php版微信開發(fā)之接收消息,自動判斷及回復(fù)相應(yīng)消息的方法
- php版微信公眾平臺回復(fù)中文出現(xiàn)亂碼問題的解決方法
- 微信公眾號開發(fā)之文本消息自動回復(fù)php代碼
- 驗(yàn)證token、回復(fù)圖文\文本、推送消息的實(shí)用微信類php代碼
- PHP微信開發(fā)之模板消息回復(fù)
- PHP微信開發(fā)之文本自動回復(fù)
- PHP微信開發(fā)之微信消息自動回復(fù)下所遇到的坑
相關(guān)文章
yii2.0使用Plupload實(shí)現(xiàn)帶縮放功能的多圖上傳
這篇文章主要介紹了yii2.0使用Plupload實(shí)現(xiàn)帶縮放功能的多圖上傳的相關(guān)資料,需要的朋友可以參考下2015-12-12ThinkPHP無限級分類原理實(shí)現(xiàn)留言與回復(fù)功能實(shí)例
這篇文章主要介紹了ThinkPHP無限級分類原理實(shí)現(xiàn)留言與回復(fù)功能實(shí)例,并附帶有完整的項(xiàng)目源碼下載供大家學(xué)習(xí)參考,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-10-10codeigniter集成ucenter1.6雙向通信的解決辦法
用codeigniter開發(fā)一個子網(wǎng)站,之后想和原來的論壇進(jìn)行同步,包括同步登陸和雙向通信。這篇文章主要介紹了codeigniter集成ucenter1.6雙向通信的解決辦法,需要的朋友可以參考下2014-06-06php 使用fopen函數(shù)創(chuàng)建、打開文件詳解及實(shí)例代碼
這篇文章主要介紹了php 使用fopen函數(shù)創(chuàng)建、打開文件詳解及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2016-09-09php使用wangeditor實(shí)現(xiàn)富文本遇見問題及兩種解決方法
在?PowerShell?中使用?npm?install?命令時(shí),命令行解析器可能會將?@?符號解釋為特殊字符,導(dǎo)致出現(xiàn)錯誤,遇到這樣的問題如何解決呢,下面通過本文介紹php使用wangeditor實(shí)現(xiàn)富文本-遇見問題,需要的朋友可以參考下2023-12-12