国产探花免费观看_亚洲丰满少妇自慰呻吟_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.     }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 清原| 赞皇县| 滕州市| 利辛县| 平山县| 视频| 大同县| 海城市| 万宁市| 武夷山市| 息烽县| 岳阳县| 壶关县| 凭祥市| 深水埗区| 彭水| 图们市| 天台县| 大足县| 罗平县| 牟定县| 中卫市| 通道| 榕江县| 昭平县| 德化县| 朝阳区| 邵东县| 安溪县| 嘉峪关市| 宜都市| 沁源县| 仙游县| 惠来县| 奉节县| 化州市| 安吉县| 永兴县| 赞皇县| 乌兰浩特市| 滦南县|