I am a complete newbie with Google Calendar API and PHP, I can't seem to figure out on how to implement the thing that I would like to do. Basically, I want to retrieve the events from a google calendar with calendarID of [email protected]. My current code goes something like
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_BooksService.php';
require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
$client = new Google_Client();
$client->setUseObjects(true);
$service = new Google_CalendarService($client);
try{
$events = $service->calendars->get('[email protected]');
print_r($events);
}catch(Exception $e){
echo $e;
}
I am receiving the error :
exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/calendar/v3/calendars/[email protected]: (401) Login Required' in C:\xampp\htdocs\Test\google-api-php-client\src\io\Google_REST.php:66 Stack trace: #0 C:\xampp\htdocs\Test\google-api-php-client\src\io\Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 C:\xampp\htdocs\Test\google-api-php-client\src\service\Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 C:\xampp\htdocs\Test\google-api-php-client\src\contrib\Google_CalendarService.php(300): Google_ServiceResource->__call('get', Array) #3 C:\xampp\htdocs\Test\refreshscript.php(10): Google_CalendarsServiceResource->get('webapps098@gmai...') #4 {main}
I wish anyone can help! Sorry and thank you for your understanding.