Google Calendar API - 只能更新活动一次 [英] Google Calendar API - can only update event once

查看:242
本文介绍了Google Calendar API - 只能更新活动一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与此帖中所述相同的问题:

I've encountered the same problem as described in this post:

Google日历api v3重新更新问题

也就是说,一旦创建活动并更新一旦使用Google日历API(v3),我就无法再更新活动。当我尝试,我得到一个400 - 无效的值响应。 (FWIW我在PHP工作)。

Namely, once I create an event and update it once using the Google Calendar API (v3), I am no longer able to update the event. When I attempt to, I get a 400 - Invalid value response. (FWIW I'm working in PHP).

在上面引用的帖子中提供了一个潜在客户,我尝试使用etags解决问题(尽管我承认我的掌握他们的工作是有限的)。基本上,在事件更新时,API在其响应中返回一个etag,我现在保存在我的数据库中。然后对于后续(n> 1)更新,我从数据库中取出当前etag,并将其包含在http头中:

Following a lead offered in the post I referenced above, I attempted to solve the issue using etags (though admittedly my grasp of how they work is limited). Basically, on event update, the API returns an etag in its response, which I now save in my database. Then for subsequent (n > 1) updates, I pull the current etag from the database and include it in the http header:

Content-Type:  application/json
Authorization:  OAuth [token]
If-Match: [etag]

这里的Updating Entries标题下面的信息: http://code.google.com/apis/gdata/docs/2.0/reference.html#ResourceVersioning

This follows info under the "Updating Entries" header here: http://code.google.com/apis/gdata/docs/2.0/reference.html#ResourceVersioning

Sidenote:在google ref上面,If-Match标题显示为

Sidenote: in the google ref above, the If-Match header is shown as

If-Match: "S0wCTlpIIip7ImA0X0QI"

。我用双引号保存数据库中的etags,正如在第一次更新响应中接收它们一样。使用curl_setopt / HTTPHEADER添加到标题时,我需要转义引号或其他什么吗?

with double quotes around the etag. I'm saving the etags in the database with double quotes, exactly as I receive them in first update response. Do I need to escape the quotes or anything when adding to the header using curl_setopt/HTTPHEADER?

尽管实现了这个etag If-Match的东西, 400 - 值响应无效。我知道我的请求正文是有效的,因为第一次更新工作正常。

Despite implementing this etag If-Match thing, I'm still getting the same 400 - Invalid value response. I know that my request bodies are valid because the first update works fine. There's just some additional issue surrounding subsequent updates.

任何帮助非常感激。

推荐答案

更新事件时,请务必增加序号字段。

Make sure to increment the sequence number field when updating events.

这篇关于Google Calendar API - 只能更新活动一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆