开发者

Event not updated using Google calendar API

开发者 https://www.devze.com 2023-02-22 01:36 出处:网络
I\'m trying to update events in a calendar using the google calendar API but I cant get it to work. Here is my update function.

I'm trying to update events in a calendar using the google calendar API but I cant get it to work.

Here is my update function.

I'm using pecl's oauth extension.

public function updateEvent($id,$title,$body,$start,$end){

        $calendar = $this->getCalendars();

        try {

            $feed = $this->fetch($calendar['data']['items']['0']['eventFeedLink']."/".$id);

            $feed['data']['title'] = $title;
            $feed['data']['details'] = $body;
            $feed['data']['when']['0']['start'] = $this->jsDateToGoogleDate($start);
            $feed['data']['when']['0']['end'] = $this->jsDateToGoogleDate($end);

            echo json_encode($feed);

            $this->oauth->fetch($feed['data']['selfLink'],json_encode($feed),OAUTH_HTTP_METHOD_PUT,array("Content-Type"=>"application/json","If-Match"=>"*"));

            print_r(json_decode($this->oauth->getLastResponse(),true));

        } catch (OAuthException $e){
            die("ERR : ".$e->getMessage());
        }
    }

I have no error what so ever.

The echo json_encode($feed) outputs :

{ "apiVersion" : "2.6",
  "data" : { "alternateLink" : "https://www.google.com/calendar/event?eid=bHBkam44Yjk2dDMwYXRxa2dmNzY4dmpkbWMgY3ZlcmJpbm5lbkBmcmVlLWV4cGVydC5jb20",
      "anyoneCanAddSelf" : false,
      "attendees" : [ { "displayName" : "cverbinnen@free-expert.com",
            "email" : "cverbinnen@free-expert.com",
            "rel" : "organizer"
          } ],
      "canEdit" : true,
      "created" : "2011-04-04T07:08:14.000Z",
      "creator" : { "displayName" : "Christophe Verbinnen",
          "email" : "cverbinnen@free-expert.com"
        },
      "details" : "dklj",
      "etag" : "\"F0gCQwRIeip7JGA6WhJQ\"",
      "guestsCanInviteOthers" : true,
      "guestsCanModify" : false,
      "guestsCanSeeGuests" : true,
      "id" : "lpdjn8b96t30atqkgf768vjdmc",
      "kind" : "calendar#event",
      "selfLink" : "https://www.google.com/calendar/feeds/cverbinnen%40free-expert.com/private/full/lpdjn8b96t30atqkgf768vjdmc",
      "sequence" : 0,
      "status" : "confirmed",
      "title" : "nuvo",
      "transparency" : "opaque",
      "updated" : "2011-04-04T07:08:14.000Z",
      "visibility" : "default",
      "when" : [ { "end" : "2011-04-06T13:00:00.000+02:00",
            "start" : "2011-04-06T08:30:00.000+02:00"
          } ]
    }
}

and the output from the PUT :

<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:gd='http://schemas.google.com/g/2005'>

  <id>http://www.google.com/calendar/feeds/cverbinnen%40free-expert.com/private/full/lpdjn8b96t30atqkgf768vjdmc</id>

  <published>2011-04-04T07:08:14.000Z</published>

  <updated>2011-04-04T07:08:14.000Z</updated>

  <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event' />

  <title type='text'>nuvo</title>

  <content type='text'>dklj</content>

  <link rel='alternate' type='text/html' href='ht开发者_如何学编程tps://www.google.com/calendar/event?eid=bHBkam44Yjk2dDMwYXRxa2dmNzY4dmpkbWMgY3ZlcmJpbm5lbkBmcmVlLWV4cGVydC5jb20' title='alternate' />

  <link rel='self' type='application/atom+xml' href='https://www.google.com/calendar/feeds/cverbinnen%40free-expert.com/private/full/lpdjn8b96t30atqkgf768vjdmc' />

  <link rel='edit' type='application/atom+xml' href='https://www.google.com/calendar/feeds/cverbinnen%40free-expert.com/private/full/lpdjn8b96t30atqkgf768vjdmc/63437584094' />

  <author>

    <name>Christophe Verbinnen</name>

    <email>cverbinnen@free-expert.com</email>

  </author>

  <gd:comments>

    <gd:feedLink href='https://www.google.com/calendar/feeds/cverbinnen%40free-expert.com/private/full/lpdjn8b96t30atqkgf768vjdmc/comments' />

  </gd:comments>

  <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed' />

  <gd:where />

  <gd:who email='cverbinnen@free-expert.com' rel='http://schemas.google.com/g/2005#event.organizer' valueString='cverbinnen@free-expert.com' />

  <gd:when endTime='2011-04-06T11:45:00.000+02:00' startTime='2011-04-06T08:30:00.000+02:00' />

  <gd:transparency value='http://schemas.google.com/g/2005#event.opaque' />

  <gd:visibility value='http://schemas.google.com/g/2005#event.default' />

  <gCal:anyoneCanAddSelf value='false' />

  <gCal:guestsCanInviteOthers value='true' />

  <gCal:guestsCanModify value='false' />

  <gCal:guestsCanSeeGuests value='true' />

  <gCal:sequence value='0' />

  <gCal:uid value='lpdjn8b96t30atqkgf768vjdmc@google.com' />

</entry>

As you can see the output from the PUT is not the same as the one from the feed i'm sending because i'm sending a end date a 13:00h and it returns an end date not modified( still at 11h45pm).

The Http response code is 200.

Anyone have a clue ?

Thanks for reading.


The error came from automatic redirection in pecl oauth http://pecl.php.net/bugs/bug.php?id=22628

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号