📜 ⬆️ ⬇️

Rakes, which I stepped on when crossing CRM with Google Calendar

As usually happens with boxed products, not all solutions are satisfied, and business processes have to be improved with external tools. In our case, it was difficult to work with the built-in calendar. The main problem was that it was impossible to simultaneously set the task and look at the employment of employees - at the same time there were difficulties in two adjacent departments.

We decided to introduce Google calendar:
image

Prior to this, I did not work with the Google API, so the first thing I did was find the documentation for the search;

The first rake: the specified documentation describes the objects that are now wrapped in the source code in other objects. After studying the code and searching for solutions on the Internet, I wrote the code for connecting to the calendar and added the first calendar.
')
“It's great how quickly everything turned out! We have almost everything ready, it remains a bit: add all the calendars we need and throw events into them ”, I thought and opened the calendar interface in the browser.
And here I was waited by the second rake: in the interface I did not find the added calendars. How to understand where they disappeared? I wrote code that returned a list of created calendars. It turned out that there were already 10 of them. How so - everything works, calendars are created and even returned. And in the interface they are not there ...

OK Google, what am I doing wrong?

I had to dig again. Found: calendars are added to the service account (147837410720-t2rf13ce77not3h58ubgme3q682nr54@developer.gserviceaccount.com). In order for the calendars to be visible, it turns out that they had to be added to the main one.

Add as follows:
$service = GoogleAuth::getInstance(); $scope = new Google_Service_Calendar_AclRuleScope(); $scope->setType('user'); $scope->setValue('  @gmail.com'); $rule = new Google_Service_Calendar_AclRule(); $rule->setRole('owner'); $rule->setScope($scope); $result = $service->acl->insert($calId, $rule); 

I relaxed and enjoyed, calendars were created, events were recorded, everything worked like a clock. But here I was waiting for the next rake!

Suddenly, on one heavy Monday, Google stopped accepting a token, producing an error (invalid_grant). For two days, the whole department searched for a black cat in a dark room. Found The recent change of time for winter time led to the lag of our server from the real time, and Google did not like it. After adjusting the time it worked.
While the calendars are working, we look forward to the next rake from Google.

I would be glad if this post helps someone to reduce the time for finding solutions to problems.

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


All Articles