mashirozx
V2EX  ›  Google

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

  •  
  •   mashirozx · Mar 8, 2020 · 4114 views
    This topic created in 2248 days ago, the information mentioned may be changed or developed.

    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 replies    2020-03-09 16:01:50 +08:00
    learningman
        1
    learningman  
       Mar 8, 2020
    有没有想过是我国的独特网络环境
    dot2017
        2
    dot2017  
       Mar 8, 2020
    @learningman 然而 safebrowsing.googleapis.com 是解析刀谷歌北京的
    mashirozx
        3
    mashirozx  
    OP
       Mar 8, 2020 via Android
    @dot2017
    @learningman 挂代理了,一样
    o0
        4
    o0  
       Mar 9, 2020
    谷歌还有这么神奇的接口?以前找过,但不是说要停止使用了吗,或者每天限 100 次
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2806 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 14:17 · PVG 22:17 · LAX 07:17 · JFK 10:17
    ♥ Do have faith in what you're doing.