微信調試問題

來源:互聯網
上載者:User
回複關鍵字 伺服器接收 這裡的邏輯怎麼輸出?? 比方說我收到了 xml資料 然後輸出 但有時候我這裡需要寫個數組 然後輸出 怎麼做

如果寫入檔案和資料庫表只能輸出xml和字串 不能輸出數組


回複討論(解決方案)

試過搞過,我把關健字回複條件都寫在代碼定死.沒在資料庫裡搞..

FromUserName;$toUsername = $postObj->ToUserName;$keyword = trim($postObj->Content);$key=$Msg->match($rule,$keyword);#迴圈開始,判斷使用者所發送過來的訊息,參數作用在下面的方法介紹裡面switch ( $key ){case "競猜":$Msg->picMsg($fromUsername,$toUsername,"合創盈豐上線有禮:免費競猜四位元,就中話費300元!","http://www.hcyf07.com/weixin/sdd2.jpg",'競猜',"http://www.hcyf07.com");exit();case "競猜送話費":$Msg->picMsg($fromUsername,$toUsername,"合創盈豐上線有禮:免費競猜四位元,就中話費300元!","http://www.hcyf07.com/weixin/sdd2.jpg",'競猜送話費',"http://www.hcyf07.com");exit();case "送話費":$Msg->picMsg($fromUsername,$toUsername,"合創盈豐上線有禮:免費競猜四位元,就中話費300元!","http://www.hcyf07.com/weixin/sdd2.jpg",'送話費',"http://www.hcyf07.com");exit();case "競猜白銀":$Msg->picMsg($fromUsername,$toUsername,"合創盈豐上線有禮:免費競猜四位元,就中話費300元!","http://www.hcyf07.com/weixin/sdd2.jpg",'競猜白銀',"http://www.hcyf07.com");exit();default:$Msg->txtMsg($fromUsername,$toUsername,$default);}if(!empty( $keyword ))                  {                            $msgType = "text";          //入庫試一下             //在這裡可以判斷接收到的keyword                                        echo $resultStr;              }else{              if($event=="subscribe"){//首次關注                       $msgType = "text";                       $url = "http://www.bjcy07.com/";                       $contentStr = "您好,感謝關北京合創盈豐商品經營有限公司,北京合創盈豐商品經營有限公司是北京大宗商品證券交易所會員單位(會員席位號為007號),以現貨白銀等貴金屬的銷售、回購為主要經營項目,實行24小時買賣報價交易,同時提供貴金屬投資諮詢服務。".$url;                       $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);                      echo  $resultStr;                                        }                  echo "Input something...";              }  /* class of msg */class Msg{  public function valid()    {        $echoStr = $_GET["echostr"];        //valid signature , option        if($this->checkSignature()){         echo $echoStr;         exit;        }    }#依次為 來源使用者,發送到使用者,時間,標題,圖片地址,簡介,點擊訊息時候的連結,當然你可以修改這個順序    function picMsg($fromUsername,$toUsername,$title,$PicUrl,$Discription,$Url)    {//get post data, May be due to the different environments$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];$time = time();$textTpl = " %s %s %s news   1  <![CDATA[%s]]> %s %s %s  1  ";    $resultStr = sprintf($textTpl,$fromUsername,$toUsername,$time,$title,$Discription,$PicUrl,$Url);echo $resultStr;}function txtMsg($fromUsername,$toUsername,$contentStr) { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; $time = time(); $textTpl = " %s %s %s text %s 0 "; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $contentStr); echo $resultStr; }  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;}}#匹配使用者關鍵字function match($rule,$keyword){ $num=count($rule)+1; for($i=0;$i<$num;$i++){ if( preg_match( "/$rule[$i]/",$keyword ) ){return $rule[$i];exit();}} } } ?>
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.