我正在尝试使用abuseipdb API2检查我的电子邮件服务器的IP地址信誉 文档中给出的示例仅涵盖了shell curl
问题是我无法将shell curl --data-urlencode“ ipAddress = 118.25.6.39”转换为php-cURL GEt变量不起作用,不允许发布,不接受包含IP地址的标头> 均失败:“ detail”:“ IP地址字段为必填。”,“状态”:422
> create index sessions_teacher_idx on cdu_sessions(teacher_id);
答案 0 :(得分:0)
这对我有用。
//Setup
$api_key = 'REPLACE_YOUR_KEY';
$abuseipdb_endponint = 'https://api.abuseipdb.com/api/v2/check';
$ipToCheck = 'REPLACE_IP';
$headers = array(
'Key: ' . $api_key,
'Accept: application/json'
);
//cURL Work
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlObj, CURLOPT_URL, ($abuseipdb_endponint . '?ipAddress=' . $ipToCheck));
curl_setopt($curlObj, CURLOPT_HTTPGET, 1);
$curl_response = curl_exec($curlObj);
print_r($curl_response);
curl_close($curlObj);
响应示例:
{"data":{"ipAddress":"79.127.127.253","isPublic":true,"ipVersion":4,"isWhitelisted":false,"abuseConfidenceScore":100,"countryCode":"IR","usageType":"Data Center\/Web Hosting\/Transit","isp":"AsiaTech Data Transfer Inc PLC","domain":"asiatech.ir","totalReports":80,"lastReportedAt":"2019-04-24T01:44:51+01:00"}}[Finished in 0.9s]