Can I ask you if there is anybody who can answer me a question about Google Calendar API? I have generated credentials and on localhost it works pretty fine. I just want to return like 100 upcoming events ($service->events->listEvents($calendarId, $optParams) but this same code on production doesn`t works, it returns 500 Internal Server Error especially on this piece of code. Any advice how to continue?
this is the piece of code and it breaks on the first commented line
<?php
require './vendor/autoload.php';
$client = new Google_Client();
$gazza = new GuzzleHttp\Client([
'verify' => './cacert.pem'
]);
$client->setApplicationName('Google Calendar API PHP Quickstart');
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$client->setAuthConfig('./credentials-calendar-old.json');
$client->setAccessType('offline');
$tokenPath = 'token.json';
if (file_exists($tokenPath)) {
$accessToken = json_decode(file_get_contents($tokenPath), true);
$client->setAccessToken($accessToken);
}
$service = new Google_Service_Calendar($client);
$calendarId = 'primary';
$optParams = array(
'maxResults' => 1000,
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => date('c'),
);
$results = $service->events->listEvents($calendarId, $optParams);
$events = $results->getItems();
// Print the next 10 events on the user's calendar.
$calendarId = 'primary';
$optParams = array(
'maxResults' => 1000,
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => date('c'),
);
Thanks a lot,
Alex