public function processMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)) { $requestMsg = WxProcess::getRequestMsg($postStr); //订阅消息(subscribe),返回一条文本消息 if ($requestMsg->MsgType == MsgType::$Event && $requestMsg->EventKey == MsgType::$SUBSCRIBE) { $msgText = new MsgText(); $sql = ' select b.inputCode, t.content from t_wxcms_msg_base b,t_wxcms_msg_text t where t.base_id = b.id and b.inputCode = "' . MsgType::$SUBSCRIBE . '"'; $querySet = $msgText->queryBySql($sql); $msgContent = "欢迎订阅,请回复 1 "; //默认 if (!empty($querySet)) { $msgContent = $querySet[0]['content']; } echo WxProcess::responseText($requestMsg, $contentMsg); } else { $keyword = null; if (!empty($requestMsg->Content)) { //返回图文消息 $keyword = $requestMsg->Content; } $sql = 'select t.* from t_wxcms_msg_base b,t_wxcms_msg_news t where t.base_id = b.id '; if (!empty($keyword)) { $sql .= " and b.inputCode like '%{$keyword}%' "; } $msgNews = new MsgNews(); $querySet = $msgNews->queryBySql($sql); $newsArr = array(); if (!empty($querySet)) { $wxAccount = new Account(); $wxAccount = $wxAccount->getSingleAccount(); $msgCount = $wxAccount['msgCount']; //消息条数 if ($msgCount > count($querySet)) { $msgCount = count($querySet); } for ($i = 0; $i < $msgCount; $i++) { $item = $querySet[$i]; $news = array("Title" => $item['title'], "Description" => $item['brief'], "PicUrl" => $item['picPath'], "Url" => $item['url']); array_push($newsArr, $news); } } echo WxProcess::responseNews($requestMsg, $newsArr); } } else { echo ""; exit; } }
<?php $CUR_NAE = 'msgnews'; ?> <?php include "../static/res.php"; ?> <script type="text/javascript" > var editor = simpleKindeditor("description"); </script> </head> <?php if (isset($_GET['id']) && $_GET['id'] != '') { $sql = ' select b.id as baseId, b.inputCode, t.* from ' . ' t_wxcms_msg_base b,t_wxcms_msg_news t ' . ' where t.base_id = b.id and t.id = ' . $_GET['id']; $msgNews = new MsgNews(); $rst = $msgNews->queryBySql($sql); if (isset($rst) && count($rst) > 0) { $msgNews = $rst[0]; } } ?> <body class="bg"> <?php include "../static/top.php"; ?> <div class="content"> <div class="block-nav"> <?php include "../static/nav.php";