Reputation: 3294
I have a Google account and there are three Google Calendars in my calendar list. I am trying to create an event with selected Google Calendar. I am using 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] is a "primary
" calendar. When I create an event in this calendar, the event created successfully using PHP.
However when I try to create an event in "Contacts, Holidays in India
" calendars, it never creates event using PHP for these calendars.
My code:
$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);
Error:
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
Upvotes: 2
Views: 195
Reputation: 116968
'en.indian#[email protected]'
Is one of the many Holiday calendars that were rolled out to Google calendar in 2014. These are public calendars within Google calendar anyone can subscribe to them. However just because you have subscribed to said calendar doesn't mean that you have write access to it. In the case of the holiday calendars you have read only access.
(403) Forbidden
Means that you do not have permissions to do what ever it is you are trying to do. IN this case adding an event to a calendar you do not personally have permissions to write to.
Upvotes: 1