<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、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 模擬GET請求 ~~~ $url='http://www.baidu.com'; //網站 $ch=curl_init(); //初始化curl會話返回curl句柄(資源) curl_setopt($ch,CURLOPT_URL,$url); //設置獲取地址變量 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //以字符串形式返回 curl_exec($ch); //接收get值回來 curl_close($ch); //關閉curl連接 //以上為GET請求 ~~~ ## 模擬GET請求實戰代碼案例 ~~~ function er($url){ $u='https://api.uomg.com/api/qrcode?url='.$url; //網站 $ch=curl_init(); //初始化curl會話返回curl句柄(資源) curl_setopt($ch,CURLOPT_URL,$u); //設置獲取地址變量 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //以字符串形式返回 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //跳過https炎癥 $ma=curl_exec($ch); curl_close($ch); //關閉句柄 return base64_encode($ma); } ~~~ ![](https://img.kancloud.cn/34/23/3423c7bf47492faae9b15fd723a358f4_1379x668.png) # 模擬POST請求 ~~~ $url='http://apis.juhe.cn/qrcode/api'; //$data=['user_name'=>'liudehua']; 可以用數組 $data='key=b78526ba52010c94e266211c9c9916d5&text=http://www.baidu.com&el=&bgcolor=ffffff&fgcolor=000000&logo=&w=30&m=10&lw=10&type=1'; //可以用urlencoded方式 $ch=curl_init(); //初始化curl會話返回curl句柄(資源) curl_setopt($ch,CURLOPT_URL,$url); //設置獲取地址變量 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //以字符串形式返回 curl_setopt($ch,CURLOPT_POST,true); //POST請求方法 curl_setopt($ch,CURLOPT_POSTFIELDS,$data); //發送一個數組 $rec=curl_exec($ch); //接收POST回來 curl_close($ch); //關閉curl連接 echo $rec; ~~~ ## 第二步驟用法設置CURL的傳輸項: 官網地址: https://www.php.net/manual/zh/function.curl-setopt.php ``` CURLOPT_RETURNTRANSFER TRUE 將curl_exec()獲取的信息以字符串返回,而不是直接輸出。默認直接輸出 CURLOPT_POST TRUE 時會發送POST請求,類型為:application/x-www-form-urlencoded, 是HTML表單提交時最常見的一種。 CURLOPT_POSTFIELDS 這個參數可以是urlencoded后的字符串,類似'para1=val1&para2=val2$.....',也可以使用一個以字段名為建值,字段數位值的數組 CURLOPT_FOLLOWLOCATION TRUE 時將會根據服務器返回HTTP頭中的“Location:”重定向 ``` ## ## 有頭部文件的時候的請求: ~~~ public function oppo() { $timestamp=time(); //時間戳 $ouId='D91FF8E2ACA4435FBFC8401EED516A81bca035309b94ff5964d35ac284052076'; //從前端傳遞過來 設備識別碼 $ouId =openssl_encrypt($ouId, 'AES-128-ECB',base64_decode('XGAXicVG5GMBsx5bueOe4w=='),0,''); $josnarry = [ "ouId" => $ouId, "appType" => 3, "dataType" => 16, "ascribeType" => 1, "channel" => 1, "type" => 2, "pkg" => "com.hckz.dxkj", "timestamp" => $timestamp ]; $postData=json_encode($josnarry); //轉換為JSON字符串 $salt='e0u6fnlag06lc3pl'; //salt數據 $signature= md5( $postData.$timestamp.$salt); //json MD5后數據 dump($signature); //以下為發送POST請求 $url='https://api.ads.heytapmobi.com/api/uploadActiveData'; //請求頭部 $headers = array('signature:'.$signature,'timestamp:'.$timestamp,'Content-Type:application/json',); //頭部數組的樣式(這里一定要是這個格式) $data=[ 'ouId'=> $josnarry['ouId'], 'appType'=>$josnarry['appType'], 'dataType'=>$josnarry['dataType'], 'ascribeType'=>$josnarry['ascribeType'], 'channel'=>$josnarry['channel'], 'type'=>$josnarry['type'], 'pkg'=>$josnarry['pkg'], 'timestamp'=>$josnarry['timestamp'] ]; $data=json_encode($data); //如果頭部為JSON那么這里的數據必須是json格式 $ch=curl_init(); //初始化curl會話返回curl句柄(資源) curl_setopt($ch,CURLOPT_URL,$url); //設置獲取地址變量 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); //以字符串形式返回 curl_setopt($ch,CURLOPT_POST,true); //POST請求方法 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//設置請求頭部 curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //跳過https驗證 $rec=curl_exec($ch); //接收POST回來 curl_close($ch); //關閉curl連接 dump($rec); } ~~~ # 詳細可以看PHP中文網的問題解決: https://www.php.cn/php-ask-456762.html
                  <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>

                              哎呀哎呀视频在线观看