دامنه احراز هویت را تأیید کنید

شما می توانید یک دامنه خاص یا همه دامنه های احراز هویتی که در Postmaster ثبت کرده اید را تأیید کنید.

یک دامنه خاص را تأیید کنید

برای تأیید یک دامنه خاص، domains.get() را با نام دامنه فراخوانی کنید. نمونه کد زیر نحوه تأیید یک دامنه خاص را نشان می دهد:

جاوا

/**
   * Gets a specific domain registered by the client.
   *
   * @param service Authorized Gmail PostmasterTools API instance.
   * @param domainName The fully qualified domain name.
   * @return The domain
   * @throws IOException
   */
public static Domain getDomain(PostmasterTools service, String domainName) throws IOException {
  String query = String.format("domains/%s", domainName);
  Domain domain = service.domains().get(query).execute();
  System.out.println(domain.toPrettyString());
  return domain;
}

پایتون

"""Gets a specific domain registered by the client.

Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.

Returns:
The domain.
"""
def get_domain(service, domain_name):
  try:
      query = 'domains/' + domain_name
      domain = service.domains().get(name=query).execute();
      print(domain)
      return domain
  except errors.HttpError as err:
      print('An error occurred: %s' % err)

تمام دامنه ها را تأیید کنید

برای تأیید همه دامنه ها، domains.list() را فراخوانی کنید. در زیر نمونه کدی وجود دارد که نحوه تأیید همه دامنه ها را نشان می دهد:

جاوا

/**
   * Lists the domains that have been registered by the client.
   *
   * @param service Authorized Gmail PostmasterTools API instance.
   * @return Response message for ListDomains.
   * @throws IOException
   */
public static ListDomainsResponse listDomains(PostmasterTools service) throws IOException {
  ListDomainsResponse listDomainsResponse = service.domains().list().execute();
  for (Domain domain : listDomainsResponse.getDomains()) {
    System.out.println(domain.toPrettyString());
  }
    return listDomainsResponse;
}

پایتون

"""Lists the domains that have been registered by the client.

Args:
service: Authorized Gmail PostmasterTools API instance.

Returns:
Response message for ListDomains.
"""
def list_domains(service):
  try:
      domains = service.domains().list().execute()
      if not domains:
          print('No domains found.')
      else:
          print('Domains:')
          for domain in domains['domains']:
              print(domain)
      return domains
  except errors.HttpError as err:
      print('An error occurred: %s' % err)