javascript - 使用 JSON 更新 Google 的联系人 API

标签 javascript json gdata-api

通过 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/

相关文章:

c# - 使用 OAuth 2 和服务帐户访问旧版 GData API(电子表格 API)

java - jsp中如何解析数组列表数据和json数据

php - 在输入 mysql 之前删除 Word 格式,以获得 JSON 输出

javascript - jqGrid 查询中的子句

javascript - 使用 jQuery 解析 JSON,检索两个变量。

android - 获取 HTML 页面源代码而不是 JSON 响应

youtube - youtube gdata api不返回完整报告

c# google 电子表格输入到特定单元格

javascript - 如何获取 math.random 的值并在 if 语句中测试它?

javascript - 比较 moment.js 中的 24 小时格式时间