Example #1
0
File: index.php Project: rtens/ucdi
if (isset($_GET['logout'])) {
    unset($_SESSION['token']);
    echo "Logged-out <a href='?'>Log-in</a>";
    exit;
}
if (isset($_GET['code'])) {
    $client->authenticate($_GET['code']);
    $_SESSION['token'] = $client->getAccessToken();
    header('Location: ' . ($_SESSION['targetUrl'] ?: '/'));
    exit;
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
$redirectToAuthUrl = function () use($client) {
    $_SESSION['targetUrl'] = (string) Url::fromString($_SERVER['REQUEST_URI'])->withParameters(Collection::toCollections($_REQUEST));
    $authUrl = $client->createAuthUrl();
    header('Location: ' . $authUrl);
    exit;
};
if (!$client->getAccessToken()) {
    $redirectToAuthUrl();
}
$cal = new Google_Service_Calendar($client);
$info = new Google_Service_Oauth2($client);
try {
    $userId = $info->userinfo->get()->email;
    $userDir = __DIR__ . '/user/' . $userId;
    $settingsStore = new SettingsStore($userDir);
    $calendar = new GoogleCalendar($cal, $settingsStore->read()->calendarId);
    (new Bootstrapper($userDir, $userId, Url::fromString(dirname($baseUrl)), $calendar, $settingsStore))->runWebApp();
Example #2
0
 private function getArguments($method)
 {
     return Collection::toCollections(array_merge($this->environment->getArguments()->toArray(), $this->decodeBody($method)->toArray()));
 }