-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontroller.php
More file actions
32 lines (30 loc) · 916 Bytes
/
controller.php
File metadata and controls
32 lines (30 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once "core/controller.Class.php";
require_once "config.php";
if (isset($_GET['code'])) {
$token = $gClient->fetchAccessTokenWithAuthCode($_GET['code']);
}else{
header('Location: index.php');
exit();
}
if(isset($token["error"]) != "invalid_grant"){
// get data from google
$oAuth = new Google_Service_Oauth2($gClient);
$userData = $oAuth->userinfo_v2_me->get();
//insert data in the database
$Controller = new Controller;
echo $Controller -> insertData(
array(
'email' => $userData['email'],
'avatar' => $userData['picture'],
'picture' => $userData['picture'],
'familyName' => $userData['familyName'],
'givenName' => $userData['givenName'],
'user_name' => $userData['givenName'] .' '. $userData['familyName']
)
);
}else{
header('Location: index.php');
exit();
}
?>