https://developers.google.com/safe-browsing/v4/lookup-api
Google 提供的检测网址安全性的接口,不过按照文档 curl 返回的 json 是空的,又用 Stackoverflow 上看到的代码测试了,返回的也是空的。是我姿势不对嘛?
附代码:
<?php
$url = 'https://v2ex.com';
$apiKey = 'YOUR API KEY';
$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);
?> <pre><?php echo print_r($res, true); ?></pre> <?php
?>
1
learningman 2020-03-08 20:54:40 +08:00
有没有想过是我国的独特网络环境
|
2
dot2017 2020-03-08 21:33:00 +08:00
@learningman 然而 safebrowsing.googleapis.com 是解析刀谷歌北京的
|
3
mashirozx OP |
4
o0 2020-03-09 16:01:50 +08:00
谷歌还有这么神奇的接口?以前找过,但不是说要停止使用了吗,或者每天限 100 次
|