doujilou3903 2014-11-30 07:06
浏览 24

Google日历更新事件无法使用php工作并返回错误调用PUT 403 Forbidden

I'm struggling to update an event on google calendar. I'm using google-api-php-client. I want to update description of one event at a time using following code.

my@gmail.com is my primary account.

$currEvent    = $service->events->get("my@gmail.com", $event_id);

$currEvent->setDescription("Test DESCRIPTION");

$service->events->update("my@gmail.com", $currEvent->getId(), $currEvent);

I'm using above code to update.

Get event is returning proper result but update event is throwing following error:

Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling PUT https://www.googleapis.com/calendar/v3/calendars/my%40gmail.com/events/d6ao1oaiaa7s0aif229btheiv4?key=AIzaSyBQJ2hQzpYn8UIL97VKkg3tBFTq9nFAQUE: (403) Forbidden' in /google-api-php-client/src/Google/Http/REST.php:76 Stack trace: #0 /google-api-php-client/src/Google/Http/REST.php(41): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request)) #1 /google-api-php-client/src/Google/Client.php(548): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request)) #2 /google-api-php-client/src/Google/Service/Resource.php(190): Google_Client->execute(Object(Google_Http_Request)) #3 / in /google-api-php-client/src/Google/Http/REST.php on line 76

I've tried adding an event to google calendar using following code and it's working:

$event = new Google_Service_Calendar_Event();
    $event->setSummary('Appointment');
    $event->setLocation('test location');
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setDateTime('2014-12-12T10:00:00.000-07:00');
    $event->setStart($start);
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setDateTime('2014-12-12T10:25:00.000-07:00');
    $event->setEnd($end);
    $attendee1 = new Google_Service_Calendar_EventAttendee();
    $attendee1->setEmail('abc@test.com');
    // ...
    $attendees = array($attendee1);
    $event->attendees = $attendees;
    $createdEvent = $service->events->insert('primary', $event);

    echo $createdEvent->getId();

Any help is most appreciated.

Cheers!!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向