首页 文章

在同一帐户上的所选Google日历上创建活动

提问于
浏览
1

我有一个Google帐户,我的日历列表中有三个Google日历 . 我正在尝试使用选定的Google日历创建活动 . 我正在使用PHP .

here is list of google calendars.
+----------------------+-----------------------------------------------+
| calName              | calid                                         |
+----------------------+-----------------------------------------------+
| harish@gmail.com     | harish@gmail.com                          |
| Contacts             | #contacts@group.v.calendar.google.com         |
| Holidays in India    | en.indian#holiday@group.v.calendar.google.com |
+----------------------+-----------------------------------------------+

harish@gmail.com是一个“ primary ”日历 . 当我在此日历中创建事件时,使用PHP成功创建事件 .

但是,当我尝试在“ Contacts, Holidays in India ”日历中创建一个事件时,它永远不会使用PHP为这些日历创建事件 .

我的代码:

$event = new Google_Service_Calendar_Event(array(
            'summary' => $eventname,
            'location' => $address,
            'description' => $description,
            'start' => array(
              'dateTime' => $s,
              'timeZone' => $timezone,
            ),
            'end' => array(
              'dateTime' => $e,
              'timeZone' => $timezone,
            ),
            'attendees' => array(
              array('email' => $contactemail),
            ),
            'reminders' => array(
              'useDefault' => FALSE,
              'overrides' => array(
                array('method' => 'email', 'minutes' => 24 * 60),
                array('method' => 'popup', 'minutes' => 10),
              ),
            ),
          ));

 $calid = 'en.indian#holiday@group.v.calendar.google.com'; // this is static for now

        $event = $service->events->insert($calid, $event);

错误:

致命错误:未捕获异常'Google_Service_Exception',并显示消息“错误呼叫POST https://www.googleapis.com/calendar/v3/calendars/en.indian%23holiday%40group.v.calendar.google.com/events :( 403)Forbidden'在/var/www/myinvitebig.com/vendor/google/apiclient/src/Google /Http/REST.php:110堆栈跟踪:#0 /var/www/myinvitebig.com/vendor/google/apiclient /src/Google/Http/REST.php(62):Google_Http_REST :: decodeHttpResponse(对象(Google_Http_Request),对象(Google_Client))#1 [内部函数]:Google_Http_REST :: doExecute(对象(Google_Client),对象(Google_Http_Request) )#2 /var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Task/Runner.php(174):call_user_func_array(Array,Array)#3 /var/www/myinvitebig.com/vendor/ google / apiclient / src / Google / Http / REST.php(46):Google_Task_Runner-> run()#4 /var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Client.php(593) :Google_Http_REST :: execute(Object(Google_Client),Object(Google_Http_Request))#5 /var/www/myinvitebig.co第110行的/var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Http/REST.php中的m / vendor / google / apiclient / src / Google / Ser

1 回答

  • 1

    'en.indian#holiday@group.v.calendar.google.com'

    2014中推出到Google日历的众多假日日历之一 . 这些是Google日历中的公共日历,任何人都可以订阅它们 . 但是,仅仅因为您订阅了所述日历并不意味着您具有写入权限 . 对于假日日历,您只能阅读 .

    (403)禁止

    意味着您无权执行您正在尝试的任何操作 . 在这种情况下,将事件添加到您个人无权写入的日历中 .

相关问题