通过 Google Contacts API,您可以使用 JSON 获取联系信息,但是有没有办法使用 JSON 更新它?我的尝试没有任何成功,并且在我尝试时继续出现“序言中不允许的内容”错误(似乎表明他们在 PUT 请求中期望 XML)。
在 GET 请求中,我从以下 URL 获取: http://www.google.com/m8/feeds/contacts/user@gmail.com/full?alt=json
当我想使用 XML 更新联系人时,我 PUT 到以下类型的 URL(它因更新的联系人而异): http://www.google.com/m8/feeds/contacts/user@gmail.com/base/0
我已经尝试将 alt=json 添加到 PUT 请求中,但这只是在黑暗中尝试,因为我还没有找到任何实际文档来确认甚至可以使用 JSON 进行更新。我正在通过 Firefox 插件在 JS 中进行这种交互,所以这就是为什么我更喜欢使用 JSON(到目前为止我一直在使用 E4X 并发现它非常简陋)。
如有任何帮助,我们将不胜感激!
最佳答案
我没有看到关于“在 PUT 中使用 JSON 更新 google 联系人”的痕迹。
Google 开发指南说:
To update an existing contact, first retrieve the entry you want to update, modify it, and then send a PUT request with the updated entry in the message body to the contact's edit URL. Use the application/atom+xml content type
(来自 http://code.google.com/apis/contacts/docs/3.0/developers_guide_protocol.html#Updating )
关于javascript - 使用 JSON 更新 Google 的联系人 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1927766/