mashirozx
V2EX  ›  Google

Google 的 Safe Browsing 接口是不是挂掉了

By mashirozx at 2020 年 3 月 8 日 · 4380 次点击

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
?>
4 条回复  •  2020-03-09 16:01:50 +08:00
learningman
   1
learningman  
   2020 年 3 月 8 日
有没有想过是我国的独特网络环境
dot2017
   2
dot2017  
   2020 年 3 月 8 日
@learningman 然而 safebrowsing.googleapis.com 是解析刀谷歌北京的
mashirozx
   3
mashirozx  
OP
   2020 年 3 月 8 日 via Android
@dot2017
@learningman 挂代理了,一样
o0
   4
o0  
   2020 年 3 月 9 日
谷歌还有这么神奇的接口?以前找过,但不是说要停止使用了吗,或者每天限 100 次
© 2026 V2EX · 30ms · 3.9.8.5