Error updating google event

I am trying to update a Google calendar event, but it does not work with the default calendar. I mean, when I use the "main" calendar by default, it doesn’t work, this is my code

const USER_EVENT_TYPE='primary'; const CLASS_EVENTS='Events'; if ($googleClient->getAccessToken()) { if(!class_exists(self::CLASS_EVENTS)) { $includeApplicationFiles=Mage::getBaseDir(self::LIBRARY_PATH); foreach (glob($includeApplicationFiles.self::INCLUDE_ALL_FILES) as $retrieveFiles) { include $retrieveFiles; } $allCalendarEvents = $googleCalendar->events->listEvents(self::USER_EVENT_TYPE); foreach ($allCalendarEvents->getItems() as $getSingleEvent) { if($selectedEventValue==$getSingleEvent->summary) { $getSingleEvent->setSummary($selectedEventValue); $addEventGuests = new Google_EventAttendee(); $addEventGuests->setEmail($selectGuestValue); $invitedGuests = array($addEventGuests); $getSingleEvent->attendees = $invitedGuests; $updatedEvent = $googleCalendar->events->update(self::USER_EVENT_TYPE, $getSingleEvent->getId(),$getSingleEvent); } } } } 

With an error like this

 <br /> <b>Fatal error</b>: Uncaught exception 'Google_ServiceException' with message 'Error calling PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/5vmet3i6mmak81utnj2p0ebv8g?key=900220817963%40developer.gserviceaccount.com: (403) Forbidden' in C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php:61 Stack trace: #0 C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php(35): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 C:\xampp\htdocs\magento\lib\google-api-php-client\src\service\Google_ServiceResource.php(152): Google_REST::execute(Object(Google_HttpRequest)) #2 C:\xampp\htdocs\magento\lib\google-api-php-client\src\contrib\Google_CalendarService.php(591): Google_ServiceResource-&gt;__call('update', Array) #3 C:\xampp\htdocs\magento\app\code\local\Social\Google\Model\Google.php(360): Google_EventsServiceResource-&gt;update('primary', '5vmet3i6mmak81u...', Object(Google_Event)) #4 C:\xampp\htdocs\magento\Connectors\google\AutoCompleteCalendarEvents.php(16): Social_Goog in <b>C:\xampp\htdocs\magento\lib\google-api-php-client\src\io\Google_REST.php</b> on line <b>61</b><br /> 
+5
source share
1 answer

Without looking at all the code, I would make two sentences:

You can update your key and check your settings in the developer console. If you change the project namespace and use the same key, you may have problems.

Another thing is if you installed the developer key anywhere to remove this:

 $googleClient->setDeveloperKey('insert_key'); 

If you read the following link, this shows a number of similar problems.

https://code.google.com/p/google-api-php-client/issues/detail?id=218

I must add that 403 Forbidden indicates that you are communicating with the server successfully, but you do not have permission for this action / operation.
This is why he is leaning towards:
1. Invalid key or 2. if the key is valid and you have redefined the actual key value in your code. Thus, the representation of a new value, which (of course) is an invalid key.

Let me know if you need more help.

0
source

Source: https://habr.com/ru/post/1215136/


All Articles