Google Api creating New Client

Thursday, July 3, 2014

I am trying to deploy the code in a server which runs Ubuntu. I had previously run the code successfully in windows using Wamp server. but when i try to run it in ubuntu, I think i am not able to create a New client. I tried changing the permission of the directories and everything.

Here's the code.

<title> Search </title>
require_once 'src/Google_Client.php';
require_once 'src/Auth/Google_OAuth2.php';
require_once 'src/contrib/Google_Oauth2Service.php';
//$_SESSION['access'] = 'my_value';

$client = new Google_Client();
$client_id = 'xxx';
$client_secret = 'yyy';
$redirect_uri = 'zzz';


$oauth2 = new Google_Oauth2Service($client);

if (isset($_GET['code'])) {
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));

if (isset($_SESSION['token'])) {

if (isset($_REQUEST['logout'])) {

if ($client->getAccessToken()) {
$user = $oauth2->userinfo->get();
$_SESSION['emailid'] = $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);
$personMarkup = "$email";
$_SESSION['token'] = $client->getAccessToken();
$authUrl = $client->createAuthUrl();
header('Location: '.$authUrl);

It still runs perfectly in Wamp server.