广告客户身份验证

为了向用户提供安全可靠的广告生态系统以及遵从新出现的法规,Google 现在要求广告客户完成一个或多个验证程序

如果您需要完成验证程序,可能会为验证流程设置截止期限。如果逾期未完成验证,您的帐号可能会被暂停。

您也可以主动进行验证,而无需进行验证。IdentityVerificationService 提供了执行以下操作的方法:

  • 检索客户帐号的验证流程状态,包括任何截止期限
  • 启动验证流程

检索验证状态

如需检索客户帐号的广告客户身份验证流程的状态,请调用 GetIdentityVerification 方法:

Java

This example is not yet available in Java; you can take a look at the other languages.
    

C#

private static IdentityVerification GetIdentityVerification(
        GoogleAdsClient client, long customerId)
{
    IdentityVerificationServiceClient identityVerificationService =
        client.GetService(Services.V16.IdentityVerificationService);

    try {
        GetIdentityVerificationResponse response =
            identityVerificationService.GetIdentityVerification(
                new GetIdentityVerificationRequest()
                {
                    CustomerId = customerId.ToString()
                }
            );

            if (response.IdentityVerification.Count == 0)
            {
                return null;
            }

            IdentityVerification identityVerification = response.IdentityVerification[0];
            string deadline =
                identityVerification.IdentityVerificationRequirement.VerificationCompletionDeadlineTime;
             IdentityVerificationProgress identityVerificationProgress =
                identityVerification.VerificationProgress;
            Console.WriteLine($"Account {customerId} has a verification completion " +
                $"deadline of {deadline} and status " +
                $"{identityVerificationProgress.ProgramStatus} for advertiser identity " +
                "verification.");

            return identityVerification;
    } catch (GoogleAdsException e)
    {
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
        throw;
    }


}
      

PHP

This example is not yet available in PHP; you can take a look at the other languages.
    

Python

This example is not yet available in Python; you can take a look at the other languages.
    

Ruby

def get_identity_verification(client, customer_id)
  response = client.service.identity_verification.get_identity_verification(
    customer_id: customer_id
  )

  return nil if response.nil? || response.identity_verification.empty?

  identity_verification = response.identity_verification.first
  deadline = identity_verification.
    identity_verification_requirement.
    verification_completion_deadline_time
  progress = identity_verification.verification_progress
  puts "Account #{customer_id} has a verification completion deadline " \
    "of #{deadline} and status #{progress.program_status} for advertiser " \
    "identity verification."

  identity_verification
end
      

Perl

sub get_identity_verification {
  my ($api_client, $customer_id) = @_;

  my $response = $api_client->IdentityVerificationService()->get({
    customerId => $customer_id
  });

  if (!defined $response->{identityVerification}) {
    printf "Account %s does not require advertiser identity verification.",
      $customer_id;
    return;
  }

  my $identity_verification = $response->{identityVerification}[0];
  my $deadline = $identity_verification->{identityVerificationRequirement}
    {verificationCompletionDeadlineTime};
  my $identity_verification_progress =
    $identity_verification->{verificationProgress};

  printf "Account %s has a verification completion deadline of %s and status " .
    "%s for advertiser identity verification.", $customer_id, $deadline,
    $identity_verification_progress->{programStatus};
  return $identity_verification;
}
      

如果客户帐号注册了强制性的广告客户身份验证计划,服务会返回一个包含 IdentityVerification 对象列表的非空响应。如果响应为空,则表示客户帐号不需要进行广告客户身份验证。

从 v16 开始,Google Ads API 仅支持 ADVERTISER_IDENTITY_VERIFICATION 程序,因此这将是列表中的唯一一项。

IdentityVerification 对象包含以下属性:

开始验证过程

如果客户帐号已注册强制性的广告客户身份验证计划 - GetIdentityVerification 返回了一个非空响应,其中包含完成验证流程的截止期限,您可以通过调用 StartIdentityVerification 启动验证会话:

Java

This example is not yet available in Java; you can take a look at the other languages.
    

C#

private static void StartIdentityVerification(GoogleAdsClient client, long customerId)
{
    IdentityVerificationServiceClient identityVerificationService =
        client.GetService(Services.V16.IdentityVerificationService);

    StartIdentityVerificationRequest request = new StartIdentityVerificationRequest()
    {
        CustomerId = customerId.ToString(),
        VerificationProgram = IdentityVerificationProgram.AdvertiserIdentityVerification
    };

    try {
        identityVerificationService.StartIdentityVerification(request);
    } catch (GoogleAdsException e)
    {
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
        throw;
    }
}
      

PHP

This example is not yet available in PHP; you can take a look at the other languages.
    

Python

This example is not yet available in Python; you can take a look at the other languages.
    

Ruby

def start_identity_verification(client, customer_id)
  client.service.identity_verification.start_identity_verification(
    customer_id: customer_id,
    verification_program: :ADVERTISER_IDENTITY_VERIFICATION,
  )
end
      

Perl

sub start_identity_verification {
  my ($api_client, $customer_id) = @_;

  my $request =
    Google::Ads::GoogleAds::V16::Services::IdentityVerificationService::StartIdentityVerificationRequest
    ->new({
      customerId          => $customer_id,
      verificationProgram => ADVERTISER_IDENTITY_VERIFICATION
    });

  $api_client->AdvertiserIdentityVerificationService()
    ->start_identity_verification($request);
}
      

只有在没有另一个验证会话正在进行时,此操作才会成功;启动验证会话后,对 GetIdentityVerification 的后续调用将返回用户完成验证流程的操作网址以及操作网址的到期时间。

到期时间已过,您可以再次调用 StartIdentityVerification 以启动新的验证会话。