1

Несмотря на то, что я проверяю злонамеренный URL (http://fileserver03.com), пустой ответ возвращается с Google Safe Browsing API v4.API безопасного просмотра Google 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: {} 

ответ

3

Google Safe Browsing API v4 возвращает пустой JSON с кодом HTTP 200, если URL-адреса не указаны как «MALWARE» или любые другие «угрозы», которые вы искали.

Таким образом, вы можете попробовать другие URL-адреса, чтобы узнать, как ответ для Включенный в список URL-адреса выглядят. Попробуйте следующее:

http://goooogleadsence.biz/ 
http://activefile.ucoz.com/ 
Смежные вопросы