<?php$ch = curl_init();
$res= curl_setopt ($ch, CURLOPT_URL,"https://yoururl/cgi");curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Idc=si&");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$xyz = curl_exec ($ch);curl_close ($ch);
echo $xyz;
if ($xyz == NULL) { 
           echo "Error:<br>";
           echo curl_errno($ch) . " - " . curl_error($ch) . "<br>";
}
?>
这样试试

解决方案 »

  1.   

    Hi!I have found some information I am sure it could help lot of programmers when they want to connect with curl to any https website and they haven't a good or right CA Cert :)I give you just one example It has resolved me 2 hours of my time looking for a solution.It is simple, just if you get any error in the curl_exec (use curl_error(...) to see the error to trace it) add the next line and everything is solved:(note: replace $ch with the right curl variable)curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);<?php$ch = curl_init();
    $res= curl_setopt ($ch, CURLOPT_URL,"https://yoururl/cgi");curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "Idc=si&");
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $xyz = curl_exec ($ch);curl_close ($ch);
    echo $xyz;
    if ($xyz == NULL) { 
               echo "Error:<br>";
               echo curl_errno($ch) . " - " . curl_error($ch) . "<br>";
    }
    ?>I hope this helps.Raul Mate Galan
    Ceo Navenetworks Corp.Note: Thanks to Ruben Lopez Gea for his help too. 
      

  2.   

    $xyz 总是返回false,怎么办呢