示例#1
0
文件: index.php 项目: kingsj/zeuscart
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
if (isset($_REQUEST['logout'])) {
    unset($_SESSION['token']);
    $client->revokeToken();
}
if ($client->getAccessToken()) {
    $user = $oauth2->userinfo->get();
    // These fields are currently filtered through the PHP sanitize filters.
    // See http://www.php.net/manual/en/filter.filters.sanitize.php
    $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);
    $img = filter_var($user['picture'], FILTER_VALIDATE_URL);
    include "../../../../classes/Model/MUserRegistration.php";
    $obj = new Model_MUserRegistration();
    $obj->googleautoRegister($user);
    header("Location:google_success.php");
    $personMarkup = "{$email}<div><img src='{$img}?sz=50'></div>";
    // The access token may have been updated lazily.
    $_SESSION['token'] = $client->getAccessToken();
} else {
    $authUrl = $client->createAuthUrl();
}
?>
<!doctype html>
<html>
<head><meta charset="utf-8"></head>
<body>
<header><h1>Google UserInfo Sample App</h1></header>
<?php 
if (isset($personMarkup)) {