我开始使用Google Console API,我想尝试使用Google安全浏览来检查网站是否包含恶意软件,或者该软件对我不起作用,这是我的代码:
public function check(){
$url = 'http://www.facebokk.com';
$apiKey = 'AI6k8kgflsgjhajjfldsjqldskqO2Iq5Ou0PE';
$apiUrl = 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key='.$apiKey;
$params = [
'client' => [
'clientId' => 'foobar',
'clientVersion' => '1.2.3'
],
'threatInfo' => [
"threatTypes" =>["MALWARE", "SOCIAL_ENGINEERING"],
"platformTypes" => ["WINDOWS"],
'threatEntryTypes' => ['URL'],
'threatEntries' => [
[ 'url' => $url ]
]
]
];
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HEADER => 1,
CURLOPT_POSTFIELDS => json_encode($params),
CURLOPT_HTTPHEADER => [
'Content-Type: text/json'
]
]);
$res = curl_exec($ch);
print_r($res, true);
}
这是结果:
HTTP / 1.1 200 OK内容类型:application / json; charset = UTF-8日期:2018年9月27日星期四15:13:54 GMT服务器:ESF缓存控制:专用X-XSS-保护:1; mode = block X-Frame-Options:SAMEORIGIN X-Content-Type-Options:nosniff Alt-Svc:quic =“:443”; ma = 2592000; v =“ 44,43,39,35”接受范围:无变化:接受编码传输编码:分块{}