Вход в Google с помощью Google+ API не работает на сервере, но работает правильно на локальном хосте.
он не перенаправляет на файл domains.php после аутентификации.получение приведенного ниже URL-адреса в панели браузера.
site.com/domains/domains.php?code=4%2FsrQHdwzRfgdf4isoIuxgfddgRvhgfdfg0WbQ6eV5gfyj7I8ER
Ошибка: неустранимая ошибка: Uncaught/login_with_google/src/auth/Google_OAuth2.php
Кто-нибудь подскажет мне решение.
Ниже приведен код:
<?php
//Include GP config file && User class
include_once 'gpConfig.php';
include_once 'User.php';
if(isset($_GET['code'])){
$gClient->authenticate($_GET['code']);
$_SESSION['token'] = $gClient->getAccessToken();
header('Location: ' . filter_var($redirectURL, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$gClient->setAccessToken($_SESSION['token']);
}
if ($gClient->getAccessToken()) {
//Get user profile data from google
$gpUserProfile = $google_oauthV2->userinfo->get();
//Initialize User class
$user = new User();
//Insert or update user data to the database
$gpUserData = array(
'oauth_provider'=> 'google',
'oauth_uid' => $gpUserProfile['id'],
'first_name' => $gpUserProfile['given_name'],
'last_name' => $gpUserProfile['family_name'],
'email' => $gpUserProfile['email'],
'picture' => $gpUserProfile['picture'],
);
$userData = $user->checkUser($gpUserData);
//Storing user data into session
$_SESSION['userData'] = $userData;
//Render facebook profile data
// if(!empty($userData)){
// $output = '<h1>Google+ Profile Details </h1>';
// $output .= '<img src="'.$userData['picture'].'" width="300" height="220">';
// $output .= '<br/>Google ID : ' . $userData['oauth_uid'];
// $output .= '<br/>Name : ' . $userData['first_name'].' '.$userData['last_name'];
// $output .= '<br/>Email : ' . $userData['email'];
// $output .= '<br/>Logged in with : Google';
// $output .= '<br/>Logout from <a href="logout.php">Google</a>';
// }else{
// $output = '<h3 style="color:red">Some problem occurred, please try again.</h3>';
// }
} else {
$authUrl = $gClient->createAuthUrl();
$output = '<a href="'.filter_var($authUrl, FILTER_SANITIZE_URL).'"><img src="images/glogin.png" alt=""/></a>';
echo $output;
}
?>