Hello,
I'm trying my first steps with the calendar API and I have the problem that
i don't get access to my calender. Here's my code:
********************************************************
session_start();
require_once '../../src/Google_Client.php';
require_once '../../src/contrib/Google_CalendarService.php';
const CLIENT_ID = 'xxxx';
const SERVICE_ACCOUNT_NAME = 'xxxx';
// Make sure you keep your key.p12 file in a secure location, and isn't
// readable by others.
const KEY_FILE = 'xxxx.p12';
$client = new Google_Client();
$client->setClientId(CLIENT_ID);
$client->setApplicationName("test");
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
// Load the key in PKCS 12 format (you need to download this from the
// Google API Console when the service account was created.
$key = file_get_contents(KEY_FILE);
$client->setAssertionCredentials(new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/calendar'),
$key));
$service = new Google_CalendarService($client);
//Save token in session
if ($client->getAccessToken()) {
$_SESSION['token'] = $client->getAccessToken();
}
********************************************************
My Project Number is: 415185892367
The API Access via "Service Account" is activated and the xxx above are
only placeholders that represent my correct data.
Has anyone an idea what's wrong with my code or with my
google-developer-account-preferences?
Thanks a lot!
--
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
---
You received this message because you are subscribed to the Google Groups "NZ
PHP Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.