0

I am trying to lookup/scan the status of URLs with the Google Safe Browsing API v4, I tried the method I found in this link How to use Google Safe Browsing (v4) with .NET, but i get a null response returned.

Here's the code:

private async void checkUrlBtn_Click(object sender, EventArgs e)
{
    var service = new SafebrowsingService(new BaseClientService.Initializer
    {
        ApplicationName = "dotnet-client",
        ApiKey = "MY_API"
    });

    var request = service.ThreatMatches.Find(new FindThreatMatchesRequest()
    {
        Client = new ClientInfo
        {
            ClientId = "Dotnet-client",
            ClientVersion = "1.5.2"
        },
        ThreatInfo = new ThreatInfo()
        {
            ThreatTypes = new List<string> { "SOCIAL_ENGINEERING" },
            PlatformTypes = new List<string> { "PLATFORM_TYPE_UNSPECIFIED" },
            ThreatEntryTypes = new List<string> { "URL" },
            ThreatEntries = new List<ThreatEntry>
            {
                new ThreatEntry
                {
                    Url = "https://someurlIGotFromPhishtank.com"
                }
            }
        }
    });
    var response = await request.ExecuteAsync();
    string json = JsonConvert.SerializeObject(response);
    string jsonFormatted = JToken.Parse(json).ToString(Formatting.Indented);
    Console.WriteLine(jsonFormatted);
}   

My Response:

{
  "matches": null,
  "ETag": null
}

At this point I feel I am doing something very wrong and I need HELP!!!

4

1 回答 1

0

首先,我觉得有必要指出您刚刚在公共论坛上发布了您的私人Google API 密钥。阅读此回复后,您需要立即撤消此 API 密钥。

其次,您应该知道,仅仅因为您从一个表明它是恶意 URL 的来源获得了一个 URL,并不意味着 Google 安全浏览实际上会返回一个恶意响应。因此,您在那里得到的空响应可能只是表明 Google 安全浏览确实没有与该 URL 匹配的内容。

最后,如果我没记错的话(但我需要仔细检查才能确定),PLATFORM_TYPE_UNSPECIFIED当你提出请求时,你不能指定平台类型。您需要在请求中指定一种或多种特定平台类型。也许试试看?

于 2020-01-03T17:09:57.167 回答