Google日历更新事件 - 您的客户发出了格式错误或非法的请求

时间:2011-11-11 09:15:35

标签: php google-calendar-api gdata-api

使用API​​更新Google日历的事件时遇到一些问题。我正在尝试按照这里的说法实现它:http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#UpdatingEvents

我不确定哪些标题和正文需要附加到请求中。我发送的标题是:

'header'    => array(
    'Content-Type'      => 'application/json',
    'If-Match'      => '*',
    'GData-Version'     => 2
)

基本上,这是我的要求:

Array
(
[method] => PUT
[uri] => Array
    (
        [scheme] => https
        [host] => www.google.com
        [port] => 443
        [user] => 
        [pass] => 
        [path] => /calendar/feeds/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com/private/full/8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z
        [query] => Array
            (
            )

        [fragment] => 
    )

[version] => 1.1
[body] => {"apiVersion":"1.0","data":{"kind":"calendar#event","id":"8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z","selfLink":"https:\/\/www.google.com\/calendar\/feeds\/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com\/private\/full\/8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z","alternateLink":"https:\/\/www.google.com\/calendar\/event?eid=OHZwZzFoYThvYWhpbjhsN2swc3ZnOGt0c3NfMjAxMTExMTdUMTQwMDAwWiA2b2tuOW9ycWNxNWtnZDJrdHNzdnE2NzVrOEBn","canEdit":true,"title":"hihi","created":"2011-10-25T16:15:18.000Z","updated":"2011-11-10T13:54:27.000Z","details":"titel: \"Paintball vrouwen evenement\"\nbeschrijving: \"Dit evenement is enkele voor vrouwen\"\npersonen: \"33\"\ngroepen: \"12\"\nstatus: \"auto\"\npopulair: \"nee\"\n","status":"confirmed","creator":{"displayName":"--@gmail.com","email":"--@gmail.com"},"anyoneCanAddSelf":false,"guestsCanInviteOthers":true,"guestsCanModify":false,"guestsCanSeeGuests":true,"sequence":2,"transparency":"opaque","visibility":"private","location":"Paintball","attendees":[{"rel":"organizer","displayName":"website","email":"6okn9orqcq5kgd2ktssvq675k8@group.calendar.google.com"}],"when":[{"start":"2011-11-17T10:00:00.000Z","end":"2011-11-17T12:00:00.000Z"}],"originalEvent":{"href":"http:\/\/www.google.com\/calendar\/feeds\/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com\/private\/full\/8vpg1ha8oahin8l7k0svg8ktss","id":"8vpg1ha8oahin8l7k0svg8ktss","start":"2011-11-17T14:00:00.000Z"}}}
[line] => PUT /calendar/feeds/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com/private/full/8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z HTTP/1.1

[header] => Host: www.google.com
Connection: close
User-Agent: CakePHP
Content-Type: application/json
If-Match: *
Content-Length: 1457

[raw] => PUT /calendar/feeds/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com/private/full/8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z HTTP/1.1
Host: www.google.com
Connection: close
User-Agent: CakePHP
Content-Type: application/json
If-Match: *
Content-Length: 1457

{"apiVersion":"1.0","data":{"kind":"calendar#event","id":"8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z","selfLink":"https:\/\/www.google.com\/calendar\/feeds\/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com\/private\/full\/8vpg1ha8oahin8l7k0svg8ktss_20111117T140000Z","alternateLink":"https:\/\/www.google.com\/calendar\/event?eid=OHZwZzFoYThvYWhpbjhsN2swc3ZnOGt0c3NfMjAxMTExMTdUMTQwMDAwWiA2b2tuOW9ycWNxNWtnZDJrdHNzdnE2NzVrOEBn","canEdit":true,"title":"hihi","created":"2011-10-25T16:15:18.000Z","updated":"2011-11-10T13:54:27.000Z","details":"titel: \"Paintball vrouwen evenement\"\nbeschrijving: \"Dit evenement is enkele voor vrouwen\"\npersonen: \"33\"\ngroepen: \"12\"\nstatus: \"auto\"\npopulair: \"nee\"\n","status":"confirmed","creator":{"displayName":"--@gmail.com","email":"--@gmail.com"},"anyoneCanAddSelf":false,"guestsCanInviteOthers":true,"guestsCanModify":false,"guestsCanSeeGuests":true,"sequence":2,"transparency":"opaque","visibility":"private","location":"Paintball","attendees":[{"rel":"organizer","displayName":"website","email":"6okn9orqcq5kgd2ktssvq675k8@group.calendar.google.com"}],"when":[{"start":"2011-11-17T10:00:00.000Z","end":"2011-11-17T12:00:00.000Z"}],"originalEvent":{"href":"http:\/\/www.google.com\/calendar\/feeds\/6okn9orqcq5kgd2ktssvq675k8%40group.calendar.google.com\/private\/full\/8vpg1ha8oahin8l7k0svg8ktss","id":"8vpg1ha8oahin8l7k0svg8ktss","start":"2011-11-17T14:00:00.000Z"}}}
[cookies] => Array
    (
    )

[proxy] => Array
    (
    )

[auth] => Array
    (
    )

这是我获得400状态的回复:

您的客户发出了格式错误或非法的请求。

所以,我显然做错了什么,谁都知道呢?

1 个答案:

答案 0 :(得分:0)

由于您放置了PHP标记,我假设您使用的是PHP。您使用的是Zend Gdata框架吗?如果是,您可以在此处获得更多信息:https://code.google.com/apis/calendar/data/1.0/developers_guide_php.html

您使用的是save()方法吗?

您能否向我们提供您正在使用的代码?如果您告诉我,我将编辑此答案,以便为您提供更新的更正版本。