Google安全浏览API v4-空响应 [英] Google Safe Browsing API v4 - Empty response

查看:114
本文介绍了Google安全浏览API v4-空响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我检查了恶意URL( http://fileserver03.com ),但返回的响应为空> Google Safe Browsing API v4 .

Despite that I check a malicious URL (http://fileserver03.com), empty response returns from Google Safe Browsing API v4.

这是我尝试过的代码:

String postURL = https://safebrowsing.googleapis.com/v4/threatMatches:find?key=API_KEY

String requestBody = "{" +
        "    \"client\": {" +
        "      \"clientId\":      \"twittersentidetector\"," +
        "      \"clientVersion\": \"1.0\"" +
        "    }," +
        "    \"threatInfo\": {" +
        "      \"threatTypes\":      [\"MALWARE\", \"SOCIAL_ENGINEERING\"]," +
        "      \"platformTypes\":    [\"ANY_PLATFORM\"]," +
        "      \"threatEntryTypes\": [\"URL\"]," +
        "      \"threatEntries\": [" +
        "        {\"url\": \"http://fileserver03.com\"}," +
        "        {\"url\": \"https://bing.com\"}," +
        "        {\"url\": \"https://yahoo.com\"}" +
        "      ]" +
        "    }" +
        "  }";

URL url = new URL(postURL);
HttpURLConnection con = (HttpURLConnection) url.openConnection();

con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
con.setRequestProperty("Content-Type", "application/json");

con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(requestBody);
wr.flush();
wr.close();

int responseCode = con.getResponseCode();
System.out.println("Response Code: " + responseCode);
System.out.println("Response Message: " + con.getResponseMessage());

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String output;
StringBuffer response = new StringBuffer();

while ((output = in .readLine()) != null) {
    response.append(output);
} in .close();

System.out.println("Response: " + response.toString());

以下是输出:

Response Code: 200
Response Message: OK
Response: {}

推荐答案

Google安全浏览API v4 如果未列出 URL ,则返回带有HTTP代码200的空JSON ,作为恶意软件"或您搜索的任何其他威胁类型".

Google Safe Browsing API v4 returns empty JSON with http code 200 if URLs were not listed as "MALWARE" or any other "threatTypes" you searched for.

因此,您可以尝试其他URL来查看列出的 URL的响应. 试试这些:

So you can try other URLs to see how response for Listed URLs look like. Try these:

http://goooogleadsence.biz/
http://activefile.ucoz.com/

这篇关于Google安全浏览API v4-空响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆