在同一帐户

时间:2017-03-09 05:45:44

标签: php google-api google-calendar-api google-oauth google-api-php-client

我有一个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)禁止'在/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(Object(Google_Http_Request),Object(Google_Client))       #1 [内部函数]:Google_Http_REST :: doExecute(Object(Google_Client),Object(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))        /var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Http/REST.php中的#5 /var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Ser 在行 110

1 个答案:

答案 0 :(得分:1)

  

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

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

  

(403)禁止

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