我正在尝试使用 Google 的安全浏览查找 API(v4,https://developers.google.com/safe-browsing/v4/lookup-api https://developers.google.com/safe-browsing/v4/lookup-api)使用 .NET 应用程序,但无法找到示例代码。
我安装了 Google 的 nuget 包,但在他们的 github 存储库上找不到任何示例https://github.com/google/google-api-dotnet-client https://github.com/google/google-api-dotnet-client
我能找到的最好的例子是https://developers.google.com/api-client-library/dotnet/get_started https://developers.google.com/api-client-library/dotnet/get_started但即便如此,也没有准确地告诉我我在寻找什么。我只是想查找 URL 的状态。以下是我从谷歌找到的唯一示例。
// Create the service.
var service = new DiscoveryService(new BaseClientService.Initializer
{
ApplicationName = "Discovery Sample",
ApiKey="[YOUR_API_KEY_HERE]",
});
// Run the request.
Console.WriteLine("Executing a list request...");
var result = await service.Apis.List().ExecuteAsync();
// Display the results.
if (result.Items != null)
{
foreach (DirectoryList.ItemsData api in result.Items)
{
Console.WriteLine(api.Id + " - " + api.Title);
}
}
我也尝试过包装https://github.com/acastaner/safebrowsinglookup https://github.com/acastaner/safebrowsinglookup使用看起来相当简单
var client = new LookupClient("key", "dotnet-client");
var response = await client.LookupAsync("http://amazon.com");
但这每次都“未知”地回来。我确保我向 google 注册了一个新密钥,并授予其访问 Google Safe Browsing Api 4 的权限。
关于如何使用谷歌的API来获取一个或多个网址的响应有什么建议吗?
欣赏它!