, , . .
, PHP API Google, script ( ).
. . , Google API Access.
require_once '../../src/apiClient.php';
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
$client = new apiClient();
$client->setClientId('INSERT_CLIENT_ID');
$client->setClientSecret('INSERT_CLIENT_SECRET');
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
$client->setScopes(array(
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.readonly',
));
$authUrl = $client->createAuthUrl();
print "Please visit:\n$authUrl\n\n";
print "Please enter the auth code:\n";
$authCode = trim(fgets(STDIN));
$_GET['code'] = $authCode;
$token = $client->authenticate();
var_dump($token);
json , accessToken refreshToken. accessToken 1 , . RefreshToken ( ) refreshToken. .
json- ( access_token , . $client->setAccessToken($token), $token location ( , $token - json- , access_token).
API- !
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiCalendarService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Calendar PHP Sample Application");
$cal = new apiCalendarService($client);
$client->setAccessToken($tokenFromSafePlace);
$calList = $cal->calendarList->listCalendarList();
print "<h1>Calendar List</h1><pre>" . print_r($calList, true) . "</pre>";