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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## CURL 操作 PHP 支持 Daniel Stenberg 創建的 libcurl 庫,能夠連接通訊各種服務器、使用各種協議。libcurl 目前支持的協議有 http、https、ftp、gopher、telnet、dict、file、ldap。 libcurl 同時支持 HTTPS 證書、HTTP POST、HTTP PUT、 FTP 上傳(也能通過 PHP 的 FTP 擴展完成)、HTTP 基于表單的上傳、代理、cookies、用戶名+密碼的認證。 更多關于 CURL 請參考:[傳送門](http://php.net/manual/zh/book.curl.php) 使用 CURL 函數的基本步驟: * 首先使用 curl_init() 初始化 cURL會話。 * 接著通過 curl_setopt() 設置需要的全部選項。 * 然后使用 curl_exec() 來執行會話。 * 最后使用 curl_close() 關閉會話。 ### CURL 發送 HTTP 請求 ``` <?php class HttpClient { private $url = ''; // url private $body = []; // 請求正文 private $headers = []; // 請求頭 public function __construct($url = null) { if ($url) { $this->setUrl($url); } } /** * 設置URL * @param string $url */ public function setUrl($url) { $this->url = $url; } /** * 添加請求頭信息 * @param string $header */ public function setHeader($header) { $this->headers[] = $header; } /** * 構造消息正文 * @param array */ private function setBody($data) { $this->body = $data; } /** * GET 請求 * @return array */ public function get() { return this->request(); } /** * POST 請求 * @param array $data * @return array */ public function post($data = []) { $this->setHeader('Expect:'); $this->setBody($data); return $this->request(); } private function request() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($this->headers) { curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); } if ($this->body) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->body); } $response = curl_exec($ch); curl_close($ch); list($headers, $content) = explode("\r\n\r\n", $response); return [ 'headers' => $headers, 'content' => $content, ]; } } $http = new HttpClient('http://forum-api.local/test'); /* ------------- 發送 GET 請求 ------------ */ $response = $http->get(); var_dump($response['headers']); var_dump($response-['content']); exit(); /* ------------- 發送 POST 請求 ------------ */ $data = [ 'name' => 'kate green', 'age' => 12, ]; $response = $http->post($data); var_dump($response['headers']); var_dump($response['content']); ?> ```
                  <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>

                              哎呀哎呀视频在线观看