<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # **接收消息與回復** * * * * * 消息的監聽再簡單不過了,你不需要像其它 SDK 一樣麻煩,這將會是前所未有的簡單,你可以選擇監聽所有類型或者指定某種類型,以及作出相應的響應,比如回復一條應答消息。 在本 SDK 中,服務端的操作,例如:服務器認證,監聽事件,接收用戶消息等所有微信向我們自有服務器發起請求的,都交由 Overtrue\Wechat\Server 來處理。 ## **獲取服務端實例** * * * * * ~~~ use Overtrue\Wechat\Server; $appId = 'wx3cf0f39249eb0e60'; $token = 'hellotest'; $encodingAESKey = 'EJThPazwzO4k1cyXJnwQtL60zBdhWvFaHb4emv0dLVN'; // 可選 // $encodingAESKey 可以為空 $server = new Server($appId, $token, $encodingAESKey); ~~~ ## **接收消息** ~~~ $wechat->on('message', callable $callback); // 全部類型 // or $wechat->on('message', string $messageType, callable $callback); // 只監聽指定類型 ~~~ ##**參數說明:** * * * * * >[warning]1. $messageType string, 指定要處理的消息類型,ex:image >2. $callback callable, 回調函數,closure 匿名函數,或者一切可調用的方法或者函數 >3. $callback 接收一個參數:$message為用戶發送的消息對象,你可以訪問請求消息的所有屬性,比如:$message->FromUserName 得到發送消息的人的 openid,$message->MsgType 獲取消息的類型如 text 或者 image 等.(消息如果不做return回復,會執行下一個符合條件的監聽事件) **案例** ~~~ use Overtrue\Wechat\Server; use Overtrue\Wechat\Message; $appId = 'wx3cf0f39249eb0e60'; $secret = 'f1c242f4f28f735d4687abb469072a29'; $token = 'hellotest'; $encodingAESKey = 'EJThPazwzO4k1cyXJnwQtL60zBdhWvFaHb4emv0dLVN'; $server = new Server($appId, $token, $encodingAESKey); // 監聽所有類型 $server->on('message', function($message) { return Message::make('text')->content('您好!'); }); // 監聽指定類型 $server->on('message', 'image', function($message) { return Message::make('text')->content('我們已經收到您發送的圖片!'); }); $result = $server->serve(); echo $result; ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看