Thanks to http://hilite.me/
Paste your code here http://hilite.me/, it just converts your code to html highlighted format. Then you can copy paste it in compose mode and click on preview to see the magic!
Paste your code here http://hilite.me/, it just converts your code to html highlighted format. Then you can copy paste it in compose mode and click on preview to see the magic!
<?php require_once __DIR__.'/google-api-php-client-2.1.1/vendor/autoload.php'; date_default_timezone_set('asia/kolkata'); session_start(); // to find localhost and production server https if ($_SERVER['SERVER_NAME'] == "localhost") { $protocol = "http://"; }else{ $protocol = "https://"; } $redirect_uri = $protocol . $_SERVER['HTTP_HOST'] . "/index.php"; $client = new Google_Client(); $client->setAuthConfigFile('key.json'); $client->setRedirectUri($protocol . $_SERVER['HTTP_HOST'] . "/index.php"); $client->setScopes('email'); // You want to retrieve email and domain name // on logout if (isset($_REQUEST['logout'])) { unset($_SESSION['id_token_token']); } // once you get code after auth success if (isset($_GET['code'])) { $token = $client->fetchAccessTokenWithAuthCode($_GET['code']); $client->setAccessToken($token); $_SESSION['id_token_token'] = $token; header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL)); } if ( !empty($_SESSION['id_token_token']) && isset($_SESSION['id_token_token']['id_token']) ) { $client->setAccessToken($_SESSION['id_token_token']); } else { $authUrl = $client->createAuthUrl(); } // success if ($client->getAccessToken()) { $token_data = $client->verifyIdToken(); // print all the data related after auth print_r($token_data) } ?>
No comments:
Post a Comment