Address Validation API 用戶端程式庫

本頁說明如何開始使用 Address Validation API 的用戶端程式庫。

如要進一步瞭解用戶端程式庫,請參閱用戶端程式庫 已說明。

安裝用戶端程式庫

C#

若需更多資訊,請參閲 設定 C# 開發環境

Install-Package Google.Maps.AddressValidation.V1 -Pre

設定驗證

使用用戶端程式庫時 應用程式預設憑證 (ADC) 進行驗證如要瞭解如何設定 ADC,請參閱: 提供應用程式預設憑證的憑證。 如要瞭解如何使用 ADC 與用戶端程式庫,請參閱 使用用戶端程式庫進行驗證

使用用戶端程式庫

C#

using Google.Maps.AddressValidation.V1;
using Google.Type;
using System.Threading.Tasks;

public sealed partial class GeneratedAddressValidationClientSnippets
{
    /// <summary>Snippet for ValidateAddressAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task ValidateAddressRequestObjectAsync()
    {
        // Create client
        AddressValidationClient addressValidationClient = await AddressValidationClient.CreateAsync();
        // Initialize request argument(s)
        ValidateAddressRequest request = new ValidateAddressRequest
        {
            Address = new PostalAddress(),
            PreviousResponseId = "",
            EnableUspsCass = false,
            SessionToken = "",
        };
        // Make the request
        ValidateAddressResponse response = await addressValidationClient.ValidateAddressAsync(request);
    }
}

其他資源