1

選擇谷歌日曆事件我有一個谷歌帳戶,並有三個谷歌日曆我的日曆列表。我正在嘗試使用選定的Google日曆創建活動。我正在使用PHP。創建對同一賬戶

here is list of google calendars. 
+----------------------+-----------------------------------------------+ 
| calName    | calid           | 
+----------------------+-----------------------------------------------+ 
| [email protected]  | [email protected]       | 
| Contacts    | #[email protected]   | 
| Holidays in India | en.indian#[email protected] | 
+----------------------+-----------------------------------------------+ 

[email protected]是一個「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#[email protected]'; // this is static for now 

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

錯誤:


Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/calendar/v3/calendars/en.indian%23holiday%40group.v.calendar.google.com/events : (403) Forbidden' in /var/www/myinvitebig.com/vendor/google/apiclient/src/Google /Http/REST.php:110 Stack trace: #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 [internal function]: 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)) #5 /var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Ser in /var/www/myinvitebig.com/vendor/google/apiclient/src/Google/Http/REST.php on line 110

回答

1

'en.indian#[email protected]'

那是是在2014推廣到谷歌日曆中的許多假日日曆之一。這些都是Google日曆中的公共日曆,任何人都可以訂閱它們。但是僅僅因爲你已經訂閱了日曆說並不意味着你必須把它寫訪問。在假日日曆的情況下,您只能讀取訪問權限。

(403) Forbidden

表示您沒有權限執行您正在嘗試執行的操作。在這種情況下添加一個事件日曆,你不親自有寫入權限。

相關問題