我的代码中有一个问题,我想通过 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;
你能帮帮我吗?非常感谢
最佳答案
您正在设置 curl_setopt
options到 $curl
,但初始化一个新 session (并返回一个 cURL 句柄)到 $get
。您应该像这样更改 curl_setopt
行:
curl_setopt($get, CURLOPT_URL, $getbin);
curl_setopt($get, CURLOPT_RETURNTRANSFER, true);
curl_setopt($get, CURLOPT_FOLLOWLOCATION, true);
这样,您就可以为 cURL 句柄 $get
设置选项。
关于php - curl_setopt() 期望参数 1 为资源 - CURL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39189221/