如何通过电子邮件地址gmail.com获取名字和姓氏?

时间:2019-01-22 20:37:04

标签: google-api gmail gmail-api

我想通过电子邮件地址接收此人的名字和姓氏。我该怎么做?我以为可以使用Google Plus的API,但是Google正在关闭它。还有什么其他选择?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用People API。该API有一个people.get方法,该方法返回Resource: Person

{
  "resourceName": string,
  "etag": string,
  "metadata": {
    object(PersonMetadata)
  },
  "locales": [
    {
      object(Locale)
    }
  ],
  "names": [
    {
      object(Name)
    }
  ],

  ...

  "emailAddresses": [
    {
      object(EmailAddress)
    }
  ],

  ...

}

字段names将返回对象Name,其中包含以下字段:

{
  "metadata": {
    object(FieldMetadata)
  },
  "displayName": string,
  "displayNameLastFirst": string,
  "familyName": string,
  "givenName": string,
  "middleName": string,
  "honorificPrefix": string,
  "honorificSuffix": string,
  "phoneticFullName": string,
  "phoneticFamilyName": string,
  "phoneticGivenName": string,
  "phoneticMiddleName": string,
  "phoneticHonorificPrefix": string,
  "phoneticHonorificSuffix": string
}