gpt4 book ai didi

javascript - Google Contact API v3 通过 JavaScript 未创建联系人

转载 作者:行者123 更新时间:2023-11-28 06:13:43 24 4
gpt4 key购买 nike

请问您是否可以帮忙。

我尝试通过 JavaScript 使用 Google Contact API v3 创建联系人,并使用以下默认 ATOM+XML 字符串:

  var resource = '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"    xmlns:gd="http://schemas.google.com/g/2005">  <atom:category scheme="http://schemas.google.com/g/2005#kind"    term="http://schemas.google.com/contact/2008#contact"/>  <gd:name>     <gd:givenName>Elizabeth</gd:givenName>     <gd:familyName>Bennet</gd:familyName>     <gd:fullName>Elizabeth Bennet</gd:fullName>  </gd:name>  <atom:content type="text">Notes</atom:content>  <gd:email rel="http://schemas.google.com/g/2005#work"    primary="true"    address="liz@gmail.com" displayName="E. Bennet"/>  <gd:email rel="http://schemas.google.com/g/2005#home"    address="liz@example.org"/>  <gd:phoneNumber rel="http://schemas.google.com/g/2005#work"    primary="true">    (206)555-1212  </gd:phoneNumber>  <gd:phoneNumber rel="http://schemas.google.com/g/2005#home">    (206)555-1213  </gd:phoneNumber>  <gd:im address="liz@gmail.com"    protocol="http://schemas.google.com/g/2005#GOOGLE_TALK"    primary="true"    rel="http://schemas.google.com/g/2005#home"/>  <gd:structuredPostalAddress      rel="http://schemas.google.com/g/2005#work"      primary="true">    <gd:city>Mountain View</gd:city>    <gd:street>1600 Amphitheatre Pkwy</gd:street>    <gd:region>CA</gd:region>    <gd:postcode>94043</gd:postcode>    <gd:country>United States</gd:country>    <gd:formattedAddress>      1600 Amphitheatre Pkwy Mountain View    </gd:formattedAddress>  </gd:structuredPostalAddress></atom:entry>';

以及以下请求:

 gapi.client.request({
'path': '/m8/feeds/contacts/default/full',
'headers': { 'Content-Type': 'application/atom+xml', 'GData-Version': 3.0 },
'method': 'POST',
'body': resource,
'callback': writeResponse
});

我得到的原始响应似乎在最后说它已创建正常:

{"gapiRequest":{"data":{"body":"\n\n http://www.google.com/m8/feeds/contacts/martinkeywood%40gmail.com/base/2c9884718f97c163\n 2016-03-22T10:23:42.228Z\n 2016-03-22T10:23:42.228Z\n \n \n Notes\n \n \n \n \n Elizabeth Bennet\n Elizabeth\n Bennet\n \n \n \n \n  (206)555-1212 \n  (206)555-1213 \n \n  1600 Amphitheatre Pkwy Mountain View \n 1600 Amphitheatre Pkwy\n Mountain View\n CA\n 94043\n United States\n \n\n","headers":{"ETag":"\"Q3w5cDVSLit7I2A9XRNbFkkIRQY.\"","Vary":"X-Origin","Content-Type":"application/atom+xml; charset=UTF-8","Date":"Tue, 22 Mar 2016 10:23:42 GMT","Expires":"Tue, 22 Mar 2016 10:23:42 GMT","Cache-Control":"private, max-age=0","Server":"GSE","Transfer-Encoding":"chunked"},"status":201,"statusText":"Created"}}}

但该联系人根本没有出现在我的 Google 通讯录中。

请问有什么想法吗?

最佳答案

要将联系人创建到“所有联系人”组中,您需要在联系人 XML 数据中分配“groupMembershipInfo”。

"<gContact:groupMembershipInfo deleted=\"false\" href=\"http://www.google.com/m8/feeds/groups/{USER EMAIL}/base/6\"/>"

甚至您也可以使用 Google Contacts API Version 3.0 获取所有组 ID 。请参阅“使用联系人组”部分。获取所有 groupMembershipInfo 列表后,您可以通过将 groupId 提供给上面代码行的“6”位置来创建您想要的群组的联系人。

关于javascript - Google Contact API v3 通过 JavaScript 未创建联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36151847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com