是否有 sdk/lib 来解析 Google Contact API v3 返回的 gdata (json) 数据?
Is there a sdk/lib to parse gdata (json) data returned by the Google Contact API v3?
我目前正在通过 GoogleContact API v3 访问 google 联系人。我使用以下命令:
"https://www.google.com/m8/feeds/contacts/default/full?access_token=" + token.access_token + "&alt=json&v=3&q=Susan"
它 returns 我是 gdata 格式的 json 结构响应。
{
"version": "1.0",
"encoding": "UTF-8",
"feed": {
"xmlns": "http://www.w3.org/2005/Atom",
"xmlns$openSearch": "http://a9.com/-/spec/opensearch/1.1/",
"xmlns$batch": "http://schemas.google.com/gdata/batch",
"xmlns$gd": "http://schemas.google.com/g/2005",
"xmlns$gContact": "http://schemas.google.com/contact/2008",
"gd$etag": "W/\"A0IGQ3gycSt7I2A9XR5WEk4.\"",
"id": {
"$t": "firstlast@gmail.com"
},
"updated": {
"$t": "2017-01-24T06:32:02.699Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"$t": "User1 contact"
},
"link": [{
"rel": "alternate",
"type": "text/html",
"href": "http://www.google.com/"
}, {
"rel": "http://schemas.google.com/g/2005#feed",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/darewreckk%40gmail.com/full?v=3"
}, {
"rel": "http://schemas.google.com/g/2005#post",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/full?v=3"
}, {
"rel": "http://schemas.google.com/g/2005#batch",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/full/batch?v=3"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/full?alt=json&q=First&max-results=25&v=3"
}],
"author": [{
"name": {
"$t": "First Last"
},
"email": {
"$t": "firstlast@gmail.com"
}
}],
"generator": {
"version": "1.0",
"uri": "http://www.google.com/m8/feeds",
"$t": "Contacts"
},
"openSearch$totalResults": {
"$t": "2"
},
"openSearch$startIndex": {
"$t": "1"
},
"openSearch$itemsPerPage": {
"$t": "25"
},
"entry": [{
"gd$etag": "\"QHc9fjVSLyt7I2A9WxBXFUgKRAI.\"",
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/base/8"
},
"updated": {
"$t": "2010-01-26T23:59:21.966Z"
},
"app$edited": {
"xmlns$app": "http://www.w3.org/2007/app",
"$t": "2010-01-26T23:59:21.966Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"$t": "FirstName LastName"
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/first.name%40gmail.com/8?v=3"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/first.name%40gmail.com/full/8?v=3"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/first.name%40gmail.com/full/8?v=3"
}],
"gd$name": {
"gd$fullName": {
"$t": "First Last"
},
"gd$givenName": {
"$t": "First"
},
"gd$familyName": {
"$t": "Last"
}
},
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "firstlast@hotmail.com",
"primary": "true"
}]
}, {
"gd$etag": "\"RX0_cTVSLyt7I2A9WxFTEUUKRwY.\"",
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/first.last%40gmail.com/base/7cba75689bbb171"
},
"updated": {
"$t": "2010-04-02T03:47:04.349Z"
},
"app$edited": {
"xmlns$app": "http://www.w3.org/2007/app",
"$t": "2010-04-02T03:47:04.349Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#photo",
"type": "image/*",
"href": "LinkUrl"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "SelfUrl3"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "EditUrl3"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "first.last@gmail.com",
"primary": "true"
}]
}]
}
}
目前,我有响应并创建了我自己的方法来访问每个字段。是否有一个已经定义的库可以将其转换为更具可读性的对象?
例如,"gd$name" 我猜是名字的 google 数据表示。有没有一种方法可以将它转换为 gData 联系人对象,从而在无需编写自己的 gData 解析器的情况下为我提供名称字段?
谢谢
德里克
可在此处找到 API 参考资料:https://developers.google.com/google-apps/contacts/v3/
可在此处找到 .NET SDK(客户端库):https://www.nuget.org/packages/Google.GData.Contacts/
可以在 API 参考中找到有关如何使用客户端库的示例。
我目前正在通过 GoogleContact API v3 访问 google 联系人。我使用以下命令:
"https://www.google.com/m8/feeds/contacts/default/full?access_token=" + token.access_token + "&alt=json&v=3&q=Susan"
它 returns 我是 gdata 格式的 json 结构响应。
{
"version": "1.0",
"encoding": "UTF-8",
"feed": {
"xmlns": "http://www.w3.org/2005/Atom",
"xmlns$openSearch": "http://a9.com/-/spec/opensearch/1.1/",
"xmlns$batch": "http://schemas.google.com/gdata/batch",
"xmlns$gd": "http://schemas.google.com/g/2005",
"xmlns$gContact": "http://schemas.google.com/contact/2008",
"gd$etag": "W/\"A0IGQ3gycSt7I2A9XR5WEk4.\"",
"id": {
"$t": "firstlast@gmail.com"
},
"updated": {
"$t": "2017-01-24T06:32:02.699Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"$t": "User1 contact"
},
"link": [{
"rel": "alternate",
"type": "text/html",
"href": "http://www.google.com/"
}, {
"rel": "http://schemas.google.com/g/2005#feed",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/darewreckk%40gmail.com/full?v=3"
}, {
"rel": "http://schemas.google.com/g/2005#post",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/full?v=3"
}, {
"rel": "http://schemas.google.com/g/2005#batch",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/full/batch?v=3"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/full?alt=json&q=First&max-results=25&v=3"
}],
"author": [{
"name": {
"$t": "First Last"
},
"email": {
"$t": "firstlast@gmail.com"
}
}],
"generator": {
"version": "1.0",
"uri": "http://www.google.com/m8/feeds",
"$t": "Contacts"
},
"openSearch$totalResults": {
"$t": "2"
},
"openSearch$startIndex": {
"$t": "1"
},
"openSearch$itemsPerPage": {
"$t": "25"
},
"entry": [{
"gd$etag": "\"QHc9fjVSLyt7I2A9WxBXFUgKRAI.\"",
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/firstlast%40gmail.com/base/8"
},
"updated": {
"$t": "2010-01-26T23:59:21.966Z"
},
"app$edited": {
"xmlns$app": "http://www.w3.org/2007/app",
"$t": "2010-01-26T23:59:21.966Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"$t": "FirstName LastName"
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/first.name%40gmail.com/8?v=3"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/first.name%40gmail.com/full/8?v=3"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/first.name%40gmail.com/full/8?v=3"
}],
"gd$name": {
"gd$fullName": {
"$t": "First Last"
},
"gd$givenName": {
"$t": "First"
},
"gd$familyName": {
"$t": "Last"
}
},
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "firstlast@hotmail.com",
"primary": "true"
}]
}, {
"gd$etag": "\"RX0_cTVSLyt7I2A9WxFTEUUKRwY.\"",
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/first.last%40gmail.com/base/7cba75689bbb171"
},
"updated": {
"$t": "2010-04-02T03:47:04.349Z"
},
"app$edited": {
"xmlns$app": "http://www.w3.org/2007/app",
"$t": "2010-04-02T03:47:04.349Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#photo",
"type": "image/*",
"href": "LinkUrl"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "SelfUrl3"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "EditUrl3"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "first.last@gmail.com",
"primary": "true"
}]
}]
}
}
目前,我有响应并创建了我自己的方法来访问每个字段。是否有一个已经定义的库可以将其转换为更具可读性的对象?
例如,"gd$name" 我猜是名字的 google 数据表示。有没有一种方法可以将它转换为 gData 联系人对象,从而在无需编写自己的 gData 解析器的情况下为我提供名称字段?
谢谢 德里克
可在此处找到 API 参考资料:https://developers.google.com/google-apps/contacts/v3/
可在此处找到 .NET SDK(客户端库):https://www.nuget.org/packages/Google.GData.Contacts/
可以在 API 参考中找到有关如何使用客户端库的示例。