在http的head中传递参数。

function httpCurl($url,  $postData = array(), $isSsl = 0,$timeout=10)
{
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_HTTPHEADER, $postData);
   curl_setopt ( $ch, CURLOPT_POST, count ( $postData ));
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt ( $ch, CURLOPT_URL, $url );
   curl_setopt ( $ch, CURLOPT_POSTFIELDS, http_build_query ( $postData ) );
   curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
   curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

   if ($isSsl > 0) {
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
   }
   $result = curl_exec($ch);
   if (curl_errno($ch)) {
       $msg = "请求URL:" . $url . " 参数:".var_export($postData,true).",错误:" . curl_error($ch);
   } else {
       $res = is_array($result) ? var_export($result) : $result;
       $msg = "请求URL:" . $url . "参数:".var_export($postData,true).",返回结果:" . $res;
   }
   log($msg);
   curl_close($ch);
   return $result;
}

你可能感兴趣的:(传递参数,head)