Ejemplo n.º 1
0
$classLoader->addToClasspath(ROOT . "json-to-mysql/");
$classLoader->addToClasspath(ROOT . "automatic-php-api/Automatic/");

// start session for tracking logged in user
session_start();

// create global objects

$mysql = new MySQLConn(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASS);
$db = new JSONtoMYSQL($mysql);
$app = new EasyApp($db);



if(isset($_GET["logout"])){
	$app->logout();
    header('Location: ' . AUTOMATIC_REDIRECT_URI);
    die();
}else if (isset($_GET['code'])) {
	$app->validateLoginForCode($_GET["code"]);    
    header('Location: ' . AUTOMATIC_REDIRECT_URI);
    die('Redirect');
}else if(isset($_GET['automatic_login'])){
	$scopes = array("scope:vehicle",
					"scope:trip:summary",
					"scope:notification:speeding",
					"scope:notification:hard_brake",
					"scope:notification:hard_accel");
	$auth_url = $app->automatic()->authenticationURLForScopes($scopes);
    header('Location: ' . $auth_url);
    die('Redirect');