XAMPP,cURL,PHP - cURL没有执行

时间:2012-01-26 13:23:55

标签: php apache curl

我正试图通过家中的cURL访问我的信用卡清算公司。 由于某种原因,我无法执行命令。

(我确实从我的php.ini中的extension = php_curl.dll删除了这条评论并重新启动服务器)

$url = 'https://secure.cc-company-address.com/clearingPage.aspx';

$fields = array(
            'codepage'=>'65001',
            'terminalnumber'=>'0',
            'UserName'=>'leaping',
            'SumToBill'=>'1.9',
            'Operation'=>'2'
            );

//url-ify the data for the POST
$fields_string='';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.urlencode($value).'&'; }

$fields_string=substr($fields_string,0,strlen($fields_string)-1);

$curl = curl_init();
if(!$curl)
    echo "curl not inititalized.";
curl_setopt ($curl, CURLOPT_URL, $url.'?'.$fields_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec ($curl);

if($result)
    echo " curl executed. ";
else
    echo " curl failed. ";

curl_close ($curl); 

2 个答案:

答案 0 :(得分:2)

在我的情况下使用curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);它可以使用Pushover

答案 1 :(得分:0)

为什么不正确调试它!在你启动curl_exec

之后
$contents = curl_exec($curl);
$httpcode = curl_getinfo($curl,CURLINFO_HTTP_CODE);
$httpHeaders = curl_getinfo($curl);
curl_close($curl);

if($httpcode  && $contents!='')
{
    makeLog('calls ', $URL.' resp c:'.$httpcode.' r:'.$contents); 
}
else if($httpcode)
{
    makeLog('calls ', $URL.' resp c:'.$httpcode); 
}

function makeLog($function , $message='')
{
    $myFile = "errorLogs.txt";
    $fh = fopen($myFile, 'a+');
    fwrite($fh , "\n\r\n\r".$_SERVER['REMOTE_ADDR'].': '.$message.' -'.$function."\n\r\n\r");
}