国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

常用的curl發包函數

2024-09-04 11:49:07
字體:
來源:轉載
供稿:網友
  1. function curl($url$postFields = null)   
  2.     {   
  3.         $ch = curl_init();   
  4.         curl_setopt($ch, CURLOPT_URL, $url);   
  5.         curl_setopt($ch, CURLOPT_FAILONERROR, false);   
  6.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
  7.    
  8.         if (is_array($postFields) && 0 < count($postFields))   
  9.         {   
  10.             $postBodyString = "";   
  11.             foreach ($postFields as $k => $v)   
  12.             {   
  13.                 $postBodyString .= "$k=" . urlencode($v) . "&";    
  14.             }   
  15.             unset($k$v);   
  16.             curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);     
  17.             curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);    
  18.             curl_setopt($ch, CURLOPT_POST, true);   
  19.             curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1));   
  20.         }   
  21.         $reponse = curl_exec($ch);   
  22.         if (curl_errno($ch)){   
  23.             //throw new Exception(curl_error($ch),0);   
  24.             ShowMsg("授權出錯,請聯系管理員","/");   
  25.             exit();   
  26.         }   
  27.         else{   
  28.             $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);   
  29.             if (200 !== $httpStatusCode){   
  30.                 //throw new Exception($reponse,$httpStatusCode);   
  31.                 ShowMsg("授權出錯,請聯系管理員","/");   
  32.                 exit();   //Vevb.com 
  33.             }   
  34.         }   
  35.         curl_close($ch);   
  36.         return $reponse;   
  37.     }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 北安市| 漠河县| 广水市| 车险| 阿克| 宣武区| 论坛| 南昌县| 莎车县| 天全县| 萨迦县| 昌黎县| 栾城县| 汉川市| 铜川市| 井陉县| 合阳县| 通海县| 嵩明县| 巫山县| 淅川县| 金坛市| 肃北| 四子王旗| 剑川县| 南丹县| 宁都县| 石门县| 德阳市| 海口市| 凭祥市| 临颍县| 安陆市| 二连浩特市| 和龙市| 古田县| 柯坪县| 垦利县| 怀集县| 吴忠市| 清水河县|