<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## EasyWeChat 接入 國內中小型公司有大量的微信接入需求,[EasyWeChat](https://www.easywechat.com/) 是一個非常流行的微信開發庫,由于該庫是為 FPM 模式的傳統框架而打造,因此很多 Swoole 用戶不知道如何使用,下面詳細介紹一下 [MixPHP v2.1](https://github.com/mix-php/mix) 中如何使用。 ## Hook Guzzle 首先由于?[overtrue/wechat](https://github.com/overtrue/wechat)?是基于 GuzzleHttp 開發的,因為 GuzzleHttp 無法直接在 Swoole 中使用,所以需要先安裝 Mix Guzzle Hook,該庫能在不修改源碼的情況下讓 GuzzleHttp 協程化。 * [https://github.com/mix-php/guzzle-hook](https://github.com/mix-php/guzzle-hook) ## Request 類代理 由于 EasyWeChat 中使用的是 Symfony 框架的 Request 類,并且又不完全符合 ?[PSR-7](https://www.php-fig.org/psr/psr-7/) 規范,因此我們需要創建一個 Request 代理類: ``` <?php namespace App\Http\EasyWeChat; class Request { /** * @var \Mix\Http\Message\ServerRequest */ public $request; public function __construct(\Mix\Http\Message\ServerRequest $request) { $this->request = $request; } public function get($key) { return $this->request->getAttribute($key); } public function getContent() { return $this->request->getBody()->getContents(); } public function getContentType() { return $this->request->getHeaderLine('Content-Type'); } public function getUri() { return $this->request->getUri()->__toString(); } public function getMethod() { return $this->request->getMethod(); } } ``` ## 框架中使用 創建完成后就可在 MixPHP 的控制器中按如下代碼使用: ``` public function index(ServerRequest $request, Response $response) { $config = [ 'app_id' => 'wx3cf0f39249eb0xxx', 'secret' => 'f1c242f4f28f735d4687abb469072xxx', 'token' => 'TestToken', 'response_type' => 'array', //... ]; $app = \EasyWeChat\Factory::officialAccount($config); $app->request = new \App\Http\EasyWeChat\Request($request); $wechatResponse = $app->server->serve(); $body = (new StreamFactory())->createStream($wechatResponse->getContent()); $code = $wechatResponse->getStatusCode(); $response->withBody($body) ->withStatus($code); return $response; } ```
                  <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>

                              哎呀哎呀视频在线观看