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

2020-03-08 17:00:04 +08:00
 mashirozx

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
?>
3649 次点击
所在节点    Google
4 条回复
learningman
2020-03-08 20:54:40 +08:00
有没有想过是我国的独特网络环境
dot2017
2020-03-08 21:33:00 +08:00
@learningman 然而 safebrowsing.googleapis.com 是解析刀谷歌北京的
mashirozx
2020-03-08 22:29:24 +08:00
@dot2017
@learningman 挂代理了,一样
o0
2020-03-09 16:01:50 +08:00
谷歌还有这么神奇的接口?以前找过,但不是说要停止使用了吗,或者每天限 100 次

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/650951

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX