我的代码中有一个问题,我想通过CURL(小支付网关)获取信息,但我有下一个问题......
警告:curl_setopt()期望参数1为资源,在第12行的/home/xxxxxx/public_html/xxxxxxx/myaccount/xxxx.php中给出null
我有下一个代码行..
$getbin = 'https://binlist.net/json/".$bin."';
$get = curl_init();
curl_setopt($curl, CURLOPT_URL, $getbin);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$exec = curl_exec($get);
curl_close($get);
$cc = json_decode($exec);
$ccbrand = $cc->brand;
$ccbank = $cc->bank;
$cctype = $cc->card_type;
$ccklas = $cc->card_category;
你能帮帮我吗?非常感谢你
答案 0 :(得分:3)
您将curl_setopt
options设置为$curl
,但将新会话初始化(并返回cURL句柄)至$get
。您应该像这样更改curl_setopt
行:
curl_setopt($get, CURLOPT_URL, $getbin);
curl_setopt($get, CURLOPT_RETURNTRANSFER, true);
curl_setopt($get, CURLOPT_FOLLOWLOCATION, true);
这样,您就可以设置cURL句柄$get
的选项。