这个 PHP 文件用于通过安全浏览了解网站是否安全。
$curl = curl_init();
$certificate="C:\cacert.pem";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key= [API_KEY]',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_CAINFO => $certificate,
CURLOPT_CAPATH => $certificate,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => " {
'client': {
'clientId': 'nameclient',
'clientVersion': '1.0.0'
},
'threatInfo': {
'threatTypes': ['MALWARE', 'SOCIAL_ENGINEERING'],
'platformTypes': ['WINDOWS'],
'threatEntryTypes': ['URL'],
'threatEntries': [
{'url': 'http://www.yoytube.com/'}
]
}
}",
CURLOPT_HTTPHEADER => array(
'content-type: application/json'
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
输出应类似于此响应正文
{
"matches": [
{
"threatType": "MALWARE",
"platformType": "WINDOWS",
"threatEntryType": "URL",
"threat": {
"url": "http://www.example.org/"
},
"threatEntryMetadata": {
"entries": [{
"key": "malware_threat_type",
"value": "landing"
}]
},
"cacheDuration": "300.000s"
}
}]
}
但目前我的输出是{}
一开始我试图通过这个网址
https://sb-ssl.google.com/safebrowsing/api/lookup?client=' . CLIENT . '&apikey=' . API_KEY . '&appver=' . APP_VER . '&pver=' . PROTOCOL_VER . '&url=' . $urlToCheck
在curl_init()
,但在这种情况下,返回的状态是0