V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mashirozx
V2EX  ›  Google

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

  •  
  •   mashirozx · 2020-03-08 17:00:04 +08:00 · 3620 次点击
    这是一个创建于 1509 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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-03-08 20:54:40 +08:00
    有没有想过是我国的独特网络环境
    dot2017
        2
    dot2017  
       2020-03-08 21:33:00 +08:00
    @learningman 然而 safebrowsing.googleapis.com 是解析刀谷歌北京的
    mashirozx
        3
    mashirozx  
    OP
       2020-03-08 22:29:24 +08:00 via Android
    @dot2017
    @learningman 挂代理了,一样
    o0
        4
    o0  
       2020-03-09 16:01:50 +08:00
    谷歌还有这么神奇的接口?以前找过,但不是说要停止使用了吗,或者每天限 100 次
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2844 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:29 · PVG 23:29 · LAX 08:29 · JFK 11:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.