Skip to content

Instantly share code, notes, and snippets.

@nickstewart95
Created December 21, 2016 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickstewart95/92452d9c0e47c702250d13d6f8a682bd to your computer and use it in GitHub Desktop.
Save nickstewart95/92452d9c0e47c702250d13d6f8a682bd to your computer and use it in GitHub Desktop.
$scopes = array('https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly');
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key,
'notasecret'
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
//only get events for today
$today = date('H:i');
$current_time = strtotime($today);
$params = array(
'singleEvents' => false,
'timeMin' => (new DateTime())->format(DateTime::RFC3339),
'timeMax' => (new DateTime())->add(new DateInterval('P1D'))->format(DateTime::RFC3339)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment