Beispiel #1
0
<?php

// SESSION
ini_set('session.gc_maxlifetime', 3600);
session_set_cookie_params(3600);
session_start();
// BDD CONNECTION
$mysqli = new mysqli(null, 'root', '', 'home_presence', null, '/cloudsql/home-presence-1138:main');
if ($mysqli->connect_errno) {
    die("Echec lors de la connexion à MySQL");
}
// INCLUDES
require_once 'config/api.key.php';
require_once 'classes/OauthConnection.php';
require_once 'classes/SenseAPI.php';
require_once 'classes/Feed.php';
require_once 'classes/Utils.php';
require_once 'classes/BDD.php';
if (!OauthConnection::isConnected($mysqli)) {
    header('Location: ' . CONNECT_URI);
}
 /**
  * Set the credential's and user's information 
  * in BDD and in Cookies
  * @param array  $auth   The auth's retrieve by connect or refresh
  * @param object $mysqli The mysqli connection object
  */
 static function setting($auth, $mysqli)
 {
     $_SESSION['OAuth'] = $auth;
     $user = SenseAPI::get('https://apis.sen.se/v2/user/');
     $_SESSION['OAuth']['uid'] = $user['uid'];
     OauthConnection::registerUser($user, $mysqli);
     setcookie("APP_REFRESH_TOKEN", $_SESSION['OAuth']['refresh_token'], time() + 31536000, '/');
 }
Beispiel #3
0
<?php

require_once 'config/config.php';
if (filter_has_var(INPUT_GET, 'error')) {
    include 'error.php';
} elseif (filter_has_var(INPUT_GET, 'code')) {
    $code = filter_input(INPUT_GET, 'code');
    $token = OauthConnection::getToken($code);
    OauthConnection::setting($token, $mysqli);
    header('Location: ' . APP_URI);
}
Beispiel #4
0
<?php

require_once 'config/config.php';
OauthConnection::connect();