我最近关注了如何使用google进行身份验证的教程
他们使用此方法来提取数据
echo '<div class="welcome_txt">Welcome <b>'.$_SESSION['google_data']['given_name'].'</b></div>';
echo '<div class="google_box">';
echo '<p class="image"><img src="'.$_SESSION['google_data']['picture'].'" alt="" width="300" height="220"/></p>';
echo '<p><b>Google ID : </b>' . $_SESSION['google_data']['id'].'</p>';
echo '<p><b>Name : </b>' . $_SESSION['google_data']['name'].'</p>';
echo '<p><b>Email : </b>' . $_SESSION['google_data']['email'].'</p>';
echo '<p><b>Gender : </b>' . $_SESSION['google_data']['gender'].'</p>';
echo '<p><b>Locale : </b>' . $_SESSION['google_data']['locale'].'</p>';
echo '<p><b>Google+ Link : </b>' . $_SESSION['google_data']['link'].'</p>'
通过使用此方法如何拉封面图片。帮助我
index.php
<?php
include_once("config.php");
include_once("includes/functions.php");
//print_r($_GET);die;
if(isset($_REQUEST['code'])){
$gClient->authenticate();
$_SESSION['token'] = $gClient->getAccessToken();
header('Location: ' . filter_var($redirect_url, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$gClient->setAccessToken($_SESSION['token']);
}
if ($gClient->getAccessToken()) {
$userProfile = $google_oauthV2->userinfo->get();
//DB Insert
$gUser = new Users();
$gUser->checkUser('google',$userProfile['id'],$userProfile['given_name'],$userProfile['family_name'],$userProfile['email'],$userProfile['gender'],$userProfile['locale'],$userProfile['link'],$userProfile['picture']);
$_SESSION['google_data'] = $userProfile; // Storing Google User Data in Session
header("location: feed.php");
$_SESSION['token'] = $gClient->getAccessToken();
} else {
$authUrl = $gClient->createAuthUrl();
}
?>