以下是查看哪个网址可以安全浏览的代码。我使用了google api。 我面临的问题是我无法获得SafeBrowsing类对象来命中给定的URL。 亲切地看看是否有人有解决方案。
if ($scope.model.pageState === condition) {
$scope.model.disableDate = true;
}
答案 0 :(得分:1)
试试这个。
public final NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
public static final JacksonFactory GOOGLE_JSON_FACTORY = JacksonFactory.getDefaultInstance();
Safebrowsing.Builder safebrowsingBuilder = new Safebrowsing.Builder(httpTransport, GOOGLE_JSON_FACTORY, null);
Safebrowsing safebrowsing = safebrowsingBuilder.build();
FindThreatMatchesResponse findThreatMatchesResponse = safebrowsing.threatMatches().find(findThreatMatchesRequest).setKey(GOOGLE_API_KEY).execute();
List<ThreatMatch> threatMatches = findThreatMatchesResponse.getMatches();
if (threatMatches != null && threatMatches.size() > 0) {
for (ThreatMatch threatMatch : threatMatches) {
threatUrls.add(threatMatch.getThreat().getUrl());
}
}
完整的示例代码:https://github.com/kalinchih/java_google_safebrowsing_v4