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

首頁 > CMS > 織夢DEDE > 正文

dedecms織夢增加微信公眾號平臺發布插件的教程

2024-07-12 09:03:28
字體:
來源:轉載
供稿:網友

現在微信公眾號很火,基本是個網站都會再運營一個公眾號,因此我們用DEDECMS建站也需要與時俱進對接進入公眾號功能,在公眾號發布文章,提高用戶粘度

  1. 把以下代碼保存為winxin.php放到dede程序的plus目錄下.

代碼如下

查看源碼
 
打印代碼幫助
   
 
 
define("TOKEN", "weixin");require_once(dirname(__FILE__)."/..//common.inc.php");$dsql = new DedeSql(false);$wechatObj = new wechatCallback();$wechatObj->valid();class wechatCallback{private $items = '';private $articleCount = 0;private $key = '';public function valid(){$echoStr = $_GET["echostr"];//valid signature , optionif($this->checkSignature()){echo $echoStr;$this->responseMsg();exit;}}public function responseMsg(){//get post data, May be due to the different environments$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];//extract post dataif (!empty($postStr)){$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);$fromUsername = $postObj->FromUserName;$toUsername = $postObj->ToUserName;$this->keyword = strtolower(trim(("UTF-8","gb2312",$postObj->Content)));$time = time();$textTpl = "".$fromUsername."]]>".$toUsername."]]>".$time."0";$picTpl = "".$fromUsername."]]>".$toUsername."]]>".$time."%d%s1";if($this->keyword == 'hi' || $this->keyword == '您好' || $this->keyword == '你好' ||$this->keyword == 'hello2bizuser' ){$contentStr = "輸入關鍵字開始搜索!";//自定義歡迎回復;echo sprintf($textTpl, $contentStr);}else if( !empty( $this->keyword )){$this->search();if($this->articleCount == 0){$contentStr = "抱歉,沒有找到與【{$this->keyword}】相關的文章,要不你更換一下關鍵字,可能就有結果了哦 :-) ";echo sprintf($textTpl, $contentStr);}else{echo sprintf($picTpl,$this->articleCount,$this->items);}}}else {echo "";exit;}}private function search(){global $dsql;$weixin_posts = $dsql->SetQuery("Select * From `dede_archives` where title like '%".$this->keyword."%' order by id desc LIMIT 0, 5");$items = '';$dsql->Execute();while($weixin_post=$dsql->GetObject()){$title =$weixin_post->title;$excerpt = $weixin_post->description ;//獲取摘要$thumb = $weixin_post->litpic ;//獲取;$link = '/plus/view.php?aid='.$weixin_post->id;$items = $items . $this->get_item($title, $excerpt, $thumb, $link);$this->articleCount++;}if($this->articleCount > 5) $this->articleCount = 5;$this->items = $items;}private function get_item($title, $description, $picUrl, $url){if(!$description) $description = $title;return''.$description.']]>'.$_SERVER['HTTP_HOST'].$picUrl.']]>'.$_SERVER['HTTP_HOST'].$url.']]>';}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;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 崇义县| 兴山县| 康定县| 边坝县| 凤城市| 高平市| 芜湖县| 嘉荫县| 林甸县| 南和县| 含山县| 定西市| 平顺县| 金平| 宁陕县| 阳东县| 营口市| 通江县| 泰和县| 龙胜| 宁阳县| 张家川| 五寨县| 连城县| 舟曲县| 平乡县| 尚志市| 怀宁县| 方正县| 彩票| 黄大仙区| 朝阳市| 房产| 从江县| 眉山市| 柏乡县| 白朗县| 柳林县| 大兴区| 和龙市| 威信县|