使用以下代码,我的所有联系人都被创建为空(没有姓名,没有电子邮件,什么都没有)。我猜我的 json 结构是错误的。联系人 API v3 没有提供有关此架构如何在 json 中构造的信息,并且经过多次搜索后我找不到它。有人知道这个吗?
GoogleApi 方法来自 Meteor 包,请参阅:https://github.com/percolatestudio/meteor-google-api 它基本上是 http 的包装器,用于简化访问 token 自动刷新。
GoogleApi.post('/m8/feeds/contacts/default/full', {
data: {
name: {
"displayName": "Firstname",
"givenName": "Firstname",
"familyName": "FamilyName",
"fullName": "FullName"
},
emailAddresses: [{
Primary: true,
Address: "rest@test.com",
DisplayName: "displayed name"
}],
city: "testcity",
street: "Test Street 11",
postcode: "111",
country: "test",
}, function(error, answer) {
if (error) {console.log(error)}
if (answer) {console.log(answer)}
});
最佳答案
您可以做的最好的事情可能就是使用 GET 读取联系人,而不是使用 POST 创建联系人以便您可以查看它。响应 JSON 将与您为创建联系人而构建的 JSON 相同。该格式本身相当复杂且微妙(因为它是 XML 版本的往返格式,包括所有繁琐的 XML 命名空间),因此您无法猜测。
关于javascript - 无法在 Google 通讯录 api v3 上使用 javascript 创建联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42889725/