<?php

require_once '../EZAppDotNet.php';
$app = new EZAppDotNet();
// log in user
// if 'Remember me' was checked...
if (isset($_SESSION['rem'])) {
    // pass 1 into setSession in order
    // to set a cookie and session
    $token = $app->setSession(1);
} else {
    // otherwise just set session
    $token = $app->setSession();
}
// redirect user after logging in
header('Location: index.php');
Exemplo n.º 2
0
 $data = $app->getUser();
 // accessing the user's cover image
 echo '<body style="background:url(' . $data['cover_image']['url'] . ')">';
 echo '<div style="background:#fff;opacity:0.8;padding:20px;margin:10px;border-radius:15px;">';
 echo '<h1>Welcome to <a target="_blank" href="https://github.com/jdolitsky/AppDotNetPHP">';
 echo 'AppDotNetPHP</a> (the EZ version)</h1>';
 // accessing the user's name
 echo '<h3>' . $data['name'] . '</h3>';
 // accessing the user's avatar image
 echo '<img style="border:2px solid #000;" src="' . $data['avatar_image']['url'] . '" /><br>';
 // try posting to ADN
 if (isset($_POST['run_tests'])) {
     print "<hr />";
     print "<h3>Testing ADN functionality</h3>";
     print '<pre>';
     print '<b>Your access token is: </b>' . htmlspecialchars($app->setSession()) . "\n";
     $token = $app->setSession();
     print "<b>Clearing access token</b>\n";
     $app->setAccessToken(null);
     print "<b>Checking that we can no longer access app.net's API...</b>";
     print '<blockquote>';
     try {
         $denied = $app->getUser();
         print " error - we were granted access without a token?!?\n";
         exit;
     } catch (AppDotNetException $e) {
         if ($e->getCode() == 401) {
             print " success (could not get access)\n";
         } else {
             throw $e;
         }