2012-02-05 50 views
1

我发现了Google Calendar API(v2.6)的简单PHP类。PHP Google Calendar API v2.6 - updateEvent()函数

https://github.com/montania/Google-Calendar-API-PHP-Class

而且还有功能updateEvent($处理,$ ID,$ ETAG,$ JSON){...}

/** 
* Method to update an event in the calendar. 
    If $etag is submitted it won't update your event if it has been updated since 
    you last retreived it 
* @param string $handle E-mail or handle to identify the calendar 
* @param string $id  The id of the event 
* @param string $etag  The e-tag of the event (optional) 
* @param string $json  The complete json code from the event that you've 
          retrieved with the changes that you want 
* @return bool|object  Returns false on failure and object on success 
*/ 

我应该投入到$ JSON参数? 有人可以给我代码示例吗?

谢谢。

回答

3

$ json参数应该包含JSON格式的编辑过的事件,它来自您在检索日历事件时得到的响应。

这是你需要采取能够更新事件

  1. 步骤获得从日历中使用getEvents()或getEvent()方法的当前事件。
  2. 更新返回的对象的属性,以反映你想要做的事件
  3. 编码使用json_encode()JSON格式的对象的变化,并将其传递回updateEvent()方法

的谷歌日历API文档解释了这一点以及:http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#UpdatingEvents

+0

我理解这3个步骤和JSON必须包含的内容,但我不知道如何编写更改并将它们编码为JSON。 Simplyfied ...给我例子的代码$ json = json_encode($ string);例如:我想要更新名称和事件地点。 – 2012-02-06 10:36:14