我正在尝试将 Google 的安全浏览查找 API(v4,https://developers.google.com/safe-browsing/v4/lookup-api)与 .NET 应用程序一起使用,但无法找到示例代码。
我安装了 Google 的 nuget 包,但在https://github.com/google/google-api-dotnet-client的 github 存储库中找不到任何示例
我能找到的最好的例子是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,使用它看起来相当简单
var client = new LookupClient("key", "dotnet-client");
var response = await client.LookupAsync("http://amazon.com");
但这每次都“未知”。我确保我在 google 上注册了一个新密钥并授予它对 Google Safe Browsing Api 4 的访问权限。
关于如何使用 googles api 来获取一个或多个 url 的响应的任何建议?
欣赏它!