Google Calendar api v3 re-update issue

对着背影说爱祢 提交于 2020-01-10 04:04:25

问题


I'm working on google calendar and having problem with syncing data between my Calendar app on Iphone to Google Calendar. (I use google api v3) The problem is: I can update an event by code just 1 time after i created it. The next time when i try to update it, i get message code 400: bad request.

We can use google calendar explore to test this (https://code.google.com/apis/explorer/#_s=calendar&_v=v3&_m=calendars.update) by creating an event then update it 2 time.

Does any one meet this problem?


回答1:


I had this same problem and got the answer here: Google Calendar API v3 - Update Event

You can edit the same event twice, you just have to 'get' the event sequence

$event = $service->events->get("primary", $exist);

$seq=$event['sequence'];

and use $event->setSequence($seq)

when setting your update event details.




回答2:


You cannot update the same event twice. Instead, base your second update request on the new event data that is passed to the callback in the first update call (which has a new eTag) to update it the second time.




回答3:


Here is a Java code example on how to update using sequence:

Event updatedEvent; 
Calendar Service;   

updatedEvent.setSequence(Service.events().get(mCalendarId, updatedEvent.getId()).execute().getSequence());
Service.events().update(mCalendarId, updatedEvent.getId(), updatedEvent).execute();


来源:https://stackoverflow.com/questions/8574088/google-calendar-api-v3-re-update-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!