Ejemplo n.º 1
0
<?php

/**
 * Example of Logging in with the Automatic API
 */
require_once '../vendor/autoload.php';
require_once './config.php';
if (empty($clientId) || empty($clientSecret)) {
    die('Example Client ID/Secret not set, see config.php');
}
// Should be something like http://localhost/examples/display.php
$redirectUri = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('login.php', 'display.php', $_SERVER['REQUEST_URI']);
$client = new Srtfisher\Automatic\Client($clientId, $clientSecret, null, $redirectUri);
header('Location: ' . $client->getAuthentication()->getAuthorizationUrl());
Ejemplo n.º 2
0
<?php

/**
 * Example of Logging in with the Automatic API
 */
require_once '../vendor/autoload.php';
require_once './config.php';
if (!isset($_GET['token']) and !isset($_GET['code'])) {
    die('Must pass token or code.');
}
if (empty($clientId) || empty($clientSecret)) {
    die('Example Client ID/Secret not set, see config.php');
}
// Should be something like http://localhost/examples/display.php
$redirectUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$client = new Srtfisher\Automatic\Client($clientId, $clientSecret, isset($_GET['token']) ? $_GET['token'] : null, $redirectUri);
if (isset($_GET['code'])) {
    // Find the access token
    $token = $client->getAuthentication()->getAccessToken($_GET['code']);
    ?>
  <h2>Your Access Token: <code><?php 
    echo $token;
    ?>
</code></h2>

  <p>
    <a href="<?php 
    echo $redirectUri;
    ?>
?token=<?php 
    echo $token;