Пример #1
0
    }
    ?>
                </tbody>
            </table>
        <?php 
}
?>
    </div>
</div>


<?php 
if ($accessToken) {
    die;
}
$accessTokens = TokenUtils::getStoredAccessTokens();
$tokensHtml = '';
foreach ($accessTokens as $accessToken) {
    $tokensHtml .= sprintf('<li><a href="?token=%s">%s</a></li>', $accessToken->getToken(), $accessToken->getToken());
}
?>

<h2>Tokens: </h2>
<ul>
    <?php 
echo $tokensHtml;
?>
</ul>

<p><a href="connect.php">Add New Token</a></p>
Пример #2
0
<?php

/**
 * @var Geekdevs\OAuth2\Client\Provider\Cronofy $provider
 */
$provider = (require 'bootstrap.inc.php');
$searchToken = isset($_GET['token']) ? $_GET['token'] : null;
$accessToken = null;
$tokensHtml = '';
$accessToken = TokenUtils::findStoredAccessToken($searchToken);
if (!$accessToken) {
    die("Token was not found!");
}
try {
    $events = $provider->getEvents($accessToken, new \Geekdevs\OAuth2\Client\Criteria\EventCriteria(['calendars' => [$_GET['calendar_id']], 'toDate' => new \DateTime('+30days')]));
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
    var_dump($e->getMessage());
    var_dump($e->getResponseBody());
    die;
}
?>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<div class="container">
    <div class="row">
        <?php 
if (isset($events)) {
    ?>
            <h3>Events</h3>
Пример #3
0
<?php

/**
 * @var Geekdevs\OAuth2\Client\Provider\Cronofy $provider
 */
$provider = (require 'bootstrap.inc.php');
//Check incoming params (sent by cronofy)
if (!isset($_GET['code'])) {
    throw new \RuntimeException('Code not received!');
} elseif (empty($_GET['state']) || $_GET['state'] !== $_SESSION['oauth2state']) {
    throw new \RuntimeException('State does not match!');
}
//All good, lets get access token
$accessToken = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
//Save token into the file
TokenUtils::storeAccessToken($accessToken);
header('Location: index.php');
exit;