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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # HttpClientPool Http請求客戶端連接池。 [TOC] 使用方式簡單,步驟按照下面的來。 ## 步驟1 首先我們打開AppServer,添加連接池的聲明。 ```php public function initAsynPools() { parent::initAsynPools(); $this->addAsynPool('GetIPAddress',new HttpClientPool($this->config,'http://int.dpool.sina.com.cn')); $this->addAsynPool('WeiXinAPI',new HttpClientPool($this->config,'https://api.weixin.qq.com')); } ``` 我們通過繼承initAsynPools的方法為我們的框架添加了2個http連接池。 函數原型 ``` function addAsynPool($name, AsynPool $pool) ``` $name為改連接池的名稱,$pool為連接池的實例 ``` public function __construct($config, $baseUrl) ``` HttpClientPool的構造函數,$config傳框架的Config實例,$baseUrl請注意如果你要訪問https://api.weixin.qq.com/1/2/34/5/6/abc類似這樣的網址,那么它的baseUrl為https://api.weixin.qq.com。 ## 步驟2 我們打開我們需要進行訪問的代碼,以下我們假設在controller中進行訪問。 ```php /** * @var HttpClientPool */ protected $GetIPAddressHttpClient; public function initialization($controller_name, $method_name) { parent::initialization($controller_name, $method_name); $this->GetIPAddressHttpClient = get_instance()->getAsynPool('GetIPAddress'); } ``` 我們在initialization初始化函數中獲得這個HttpClientPool。 ```php public function http_ip_test() { $ip = $this->http_input->server('remote_addr'); $response = yield $this->GetIPAddressHttpClient->httpClient ->setQuery(['format' => 'json', 'ip' => $ip]) ->coroutineExecute('/iplookup/iplookup.php'); } ``` 接下來我們就可以在代碼中書寫我們需要訪問的api了。
                  <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>

                              哎呀哎呀视频在线观看