所以我有一个带有API的许可系统,尽管我几乎不了解cURL。有人可以解释我做错了什么吗?
大部分代码都是从我正在使用的API的文档中提取的。
这是我的PHP登录页面中的代码。
function checkLicense() {
$curl = curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt_array($curl,array(
CURLOPT_URL => "https://www.scriptic.xyz/wp-json/lmfwc/v2/licenses/",$licensekey,"?consumer_key=",$consumer_key,"&consumer_secret=",$consumer_secret,CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => "",CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => false,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => "GET",));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #: " . $err;
} else {
return $response;
}
}
错误:
cURL Error #: Could not resolve proxy: ?consumer_key=
编辑:当我使用数据库中的许可证密钥在“ $ licensekey”位置访问链接并填写其他两个变量时,它将返回我想要的json。
这是它返回的json
{"success":true,"data":{"id":"5","orderId":null,"productId":null,"licenseKey":"hidden-for-privacy","expiresAt":null,"validFor":"0","source":"2","status":"3","timesactivated":null,"timesactivatedMax":"0","createdAt":"2019-11-07 01:43:16","createdBy":"1","updatedAt":null,"updatedBy":null}}
编辑2:
我已将,
更改为.
$consumer_key = "hidden-for-privacy";
$consumer_secret = "hidden-for-privacy";
$licensekey = $_SESSION['key'];
function checkLicense() {
$curl = curl_init();
curl_setopt($curl,array(
CURLOPT_URL => "https://www.scriptic.xyz/wp-json/lmfwc/v2/licenses/". $licensekey ."?consumer_key=". $consumer_key ."&consumer_secret=". $consumer_secret,));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
新错误:
{"code":"lmfwc_rest_authentication_error","message":"Consumer key or secret is missing.","data":{"status":401}}