茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    微信公眾平臺DEMO(PHP)
    來源:易賢網(wǎng) 閱讀:1727 次 日期:2016-08-24 16:41:19
    溫馨提示:易賢網(wǎng)小編為您整理了“微信公眾平臺DEMO(PHP)”,方便廣大網(wǎng)友查閱!

    本人在SAE環(huán)境下搭建了CI框架(其實這個小東西用不著用框架的),直接把代碼寫在了控制器里面

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    //define your token

    define("TOKEN", "109");

    class Welcome extends CI_Controller {

      public function index()

      {

        /*

        $this->load->helper('url');

        $this->load->view('welcome_message');

        */

        // use chat response

        $this->responseMsg();

      }

      // chat response

      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;

          $MsgType = $postObj->MsgType;

          $time = time();

          switch($MsgType){

            case('text'):

              $keyword = trim($postObj->Content);

              $textTpl = "<xml>

                    <ToUserName><![CDATA[%s]]></ToUserName>

                    <FromUserName><![CDATA[%s]]></FromUserName>

                    <CreateTime>%s</CreateTime>

                    <MsgType><![CDATA[%s]]></MsgType>

                    <Content><![CDATA[%s]]></Content>

                    </xml>";

              switch($keyword){

                case(1):

                  // Need to optimize

                  // random read data from jokes

                  $sql = 'SELECT * FROM jokes';

                  $query = $this->db->query($sql);

                  $res = $query->result_array();

                  $num_rows = $query->num_rows();

                  $key = rand(0, $num_rows - 1); // Notice: The value of key is from 0.

                  //$contentStr = $key.'#'.$res[$key ]['content']; // debug

                  $contentStr = $res[$key ]['content']; 

                  break;

                case(2):

                  $contentStr = 'Your fromUsername is: '.$fromUsername; 

                  break;  

                case(3):

                  $newsTpl = "<xml>

                        <ToUserName><![CDATA[%s]]></ToUserName>

                        <FromUserName><![CDATA[%s]]></FromUserName>

                        <CreateTime>%s</CreateTime>

                        <MsgType><![CDATA[%s]]></MsgType>

                        <ArticleCount>2</ArticleCount>

                        <Articles>

                          <item>

                            <Title><![CDATA[%s]]></Title> 

                            <Description><![CDATA[%s]]></Description>

                            <PicUrl><![CDATA[%s]]></PicUrl>

                            <Url><![CDATA[%s]]></Url>

                          </item>

                          <item>

                            <Title><![CDATA[%s]]></Title>

                            <Description><![CDATA[%s]]></Description>

                            <PicUrl><![CDATA[%s]]></PicUrl>

                            <Url><![CDATA[%s]]></Url>

                          </item>

                        </Articles>

                        </xml> ";

                  $resultStr = sprintf($newsTpl, $fromUsername, $toUsername, $time,'news',

                    '百度','', 'http://www.baidu.com/img/bdlogo.gif', 'http://www.baidu.com',

                    'Google','', '', 'http://www.google.com'); // Notice: Google's logo is not suitable.

                  echo $resultStr;

                  exit; // Notice: It's exit, not break.                

                case(4):

                  $contentStr = "該功能正在開發(fā)中,敬請期待..."; 

                  break;

                /* others */

                default:

                  $contentStr = "回復(fù)數(shù)字 選擇服務(wù)\n";

                  $contentStr .= "1 笑話精選\n";

                  $contentStr .= "2 獲取您的Username...\n";  

                  $contentStr .= "3 圖文消息示例\n"; 

                  $contentStr .= "4 開發(fā)中...\n"; 

                  break;

              }

              $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, 'text', $contentStr);

              break;

            case('image'):

              $media_id = $postObj->MediaId;

              $imgTpl = "<xml>

                    <ToUserName><![CDATA[%s]]></ToUserName>

                    <FromUserName><![CDATA[%s]]></FromUserName>

                    <CreateTime>%s</CreateTime>

                    <MsgType><![CDATA[%s]]></MsgType>

                    <Image>

                      <MediaId><![CDATA[%s]]></MediaId>

                    </Image>

                    </xml>";

              $resultStr = sprintf($imgTpl, $fromUsername, $toUsername, $time, 'image', $media_id);

              break;

              // try get the id of the receive image and analyse

              /*

              $media_id = $postObj->MediaId;

              $textTpl = "<xml>

                    <ToUserName><![CDATA[%s]]></ToUserName>

                    <FromUserName><![CDATA[%s]]></FromUserName>

                    <CreateTime>%s</CreateTime>

                    <MsgType><![CDATA[%s]]></MsgType>

                    <Content><![CDATA[%s]]></Content>

                    </xml>";

              $length = strlen($media_id);

              $contentStr = "I have received the image message you sent, the id of this image is # $media_id #, and the length of media_id is # $length #";

              $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, 'text', $contentStr);

              break;

              */

            case('voice'):

              $textTpl = "<xml>

                    <ToUserName><![CDATA[%s]]></ToUserName>

                    <FromUserName><![CDATA[%s]]></FromUserName>

                    <CreateTime>%s</CreateTime>

                    <MsgType><![CDATA[%s]]></MsgType>

                    <Content><![CDATA[%s]]></Content>

                    </xml>"; 

              $contentStr = '你說啥?俺聽不見...';

              $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, 'text', $contentStr);

              break;

            /* others */

            default:

              $resultStr = "Input something...";

              break;

          }

          echo $resultStr;

        }else {

          echo "";

          exit;

        }

      }

    }

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機網(wǎng)站地址:微信公眾平臺DEMO(PHP)
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)