<?php
if (!$C->LOGIN_WITH_GPLUS) {
	$this->redirect($C->SITE_URL);	
} else {
	require_once('google/src/apiClient.php'); 
	require_once('google/src/contrib/apiPlusService.php');
	require_once('google/src/contrib/apiOauth2Service.php');
	
	// Google Objects
	$lgoogle = new apiClient();
	$lgoogle->setApplicationName("Friendly Social Network");
	$lgoogle->setClientId($C->GP_CLIENTID);
	$lgoogle->setClientSecret($C->GP_CLIENTSECRET);
	$lgoogle->setRedirectUri($C->SITE_URL.'oauthgplusData');
	$lgoogle->setScopes( array( 'https://www.googleapis.com/auth/plus.me','https://www.googleapis.com/auth/userinfo.email' ) );
	
	$lgoogleplus = new apiPlusService($lgoogle); // For getting user detail from google
	$lgoogleoauth2 = new apiOauth2Service($lgoogle); // For gettting user email from google
	
	if (isset($_SESSION['google_token'])) {
		$lgoogle->setAccessToken($_SESSION['google_token']);
	}
	
	$url = $lgoogle->createAuthUrl();
	
	$this->redirect($url);
}
?>