问题描述
在 Google People - people.connections.list 和其他 GET API 中,某些联系人不会返回生日字段的日期对象。已通过完整的人员范围 [https://www.googleapis.com/auth/contacts] 进行身份验证。
我们也不知道要解析的“文本”字段的格式,因为参数可以包含任何随机字符串。
如何解析用户的生日?什么时候不返回Date对象?
样品请求
生日回复示例
{
"birthdays": [
{
"Metadata": {
"source": {
"id": "3ebd95668aeed9d7","type": "CONTACT"
},"primary": true
},"text": "2000-07-24"
}
],"resourceName": "people/c4520933868599957975","etag": "<etag>"
},{
"birthdays": [
{
"Metadata": {
"source": {
"id": "5f5712ce0861c5b0","text": "1880-03-11"
}
],"resourceName": "people/c6869980432690169264",{
"birthdays": [
{
"date": {
"month": 1,"year": 1990,"day": 26
},"Metadata": {
"source": {
"id": "a16dde58e814a36","text": "01/26/1990"
}
],"resourceName": "people/c727012367875000886","year": 1998,"day": 1
},"Metadata": {
"source": {
"id": "f350f568dd11db1","text": "Jan 1,1998"
}
],"resourceName": "people/c1095798948755479985",{
"birthdays": [
{
"Metadata": {
"source": {
"id": "3652e00f0d28c9f4","text": "random string accept"
}
],"resourceName": "people/c3914437381388290548","etag": "<etag>"
}
]
解决方法
birthday 字段,可以采用日期或文本,并且不保证相同。