【问题标题】:Google calendar updating event - Your client has issued a malformed or illegal requestGoogle 日历更新事件 - 您的客户发出了格式错误或非法的请求
【发布时间】:2011-12-26 20:51:09
【问题描述】:

我在使用 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 状态响应:

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

所以,我显然做错了什么,有人知道吗?

【问题讨论】:

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


    【解决方案1】:

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

    你在使用 save() 方法吗?

    您能否向我们提供您正在使用的代码?如果你给我,我会编辑这个答案,给你更新的更正版本。

    【讨论】:

    • 问题与我使用的 Oauth 和 URL 中的参数有关。我使用的是 Cakephp 2.0,所以我不能使用 zend Gdata 框架。现在通过正确使用 Oauth 解决了这个问题。我还有另一个问题:stackoverflow.com/questions/8099880/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2014-02-11
    • 1970-01-01
    相关资源
    最近更新 更多