| Server IP : 188.114.97.2 / Your IP : 104.23.243.200 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/git/sms.edl.codes.solutions/application/libraries/ |
Upload File : |
<?php
require_once('google-api-client/vendor/autoload.php');
class Google {
protected $CI;
public function __construct(){
$this->CI =& get_instance();
$this->CI->load->library('session');
$this->CI->config->load('google_config');
$this->client = new Google_Client();
$this->client->setClientId($this->CI->config->item('google_client_id'));
//$this->client->setClientId("1091112128863-s0jqhb805jf8irk86olc39l18cu7j5k3.apps.googleusercontent.com");
$this->client->setClientSecret($this->CI->config->item('google_client_secret'));
$this->client->setRedirectUri($this->CI->config->item('google_redirect_url'));
$this->client->setScopes(array(
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
)
);
}
public function get_login_url(){
return $this->client->createAuthUrl();
}
public function check_token($token){
$payload = $this->client->verifyIdToken($token);
if ($payload) {
return true;
} else {
return false;
}
}
public function validate(){
if (isset($_GET['code'])) {
$this->client->authenticate($_GET['code']);
$_SESSION['access_token'] = $this->client->getAccessToken();
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$this->client->setAccessToken($_SESSION['access_token']);
$plus = new Google_Service_Plus($this->client);
$person = $plus->people->get('me');
$info['id']=$person['id'];
$info['email']=$person['emails'][0]['value'];
$info['name']=$person['displayName'];
$info['link']=$person['url'];
$info['profile_pic']=substr($person['image']['url'],0,strpos($person['image']['url'],"?sz=50")) . '?sz=800';
return $info;
}
}
}