我有这样的代码
$payUrl = (some url);
$postCheckData = 'CompanyCode=' . urlencode($companyCode) . '&ServiceCode=' . urlencode($serviceCode) and so on
$chOne = curl_init( $payUrl );
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $postCheckData);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$payResp = curl_exec( $chOne );
curl_close ($chOne);
print_r($payResp);
当我尝试运行此代码时,我得到curl_setopt(): 248 is not a valid cURL handle resource
这个错误是什么?我搜索过的解决方案都没有为我工作..可能出现的问题是什么?请帮忙
答案 0 :(得分:0)
使用$ chOne = curl_init($ payUrl)初始化curl请求;但是然后在所有其他curl_setopt调用中引用$ ch。我认为它应该是这样的:
$payUrl = (some url);
$postCheckData = 'CompanyCode=' . urlencode($companyCode) . '&ServiceCode=' . urlencode($serviceCode) and so on
$chOne = curl_init( $payUrl );
curl_setopt( $chOne, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $chOne, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $chOne, CURLOPT_POST, 1);
curl_setopt( $chOne, CURLOPT_POSTFIELDS, $postCheckData);
curl_setopt( $chOne, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $chOne, CURLOPT_HEADER, 0);
curl_setopt( $chOne, CURLOPT_RETURNTRANSFER, 1);
$payResp = curl_exec( $chOne );
curl_close( $chOne );
print_r( $payResp );