HI,
I try to load with the Loader, the src of the Google API. But, it keeps telling me the he can't find the class Google_Client.
Fatal error: Class 'Google_FileCache' not found in /usr/local/zend/apache2/htdocs/vendor/google/src/Google_Client.php on line 94
This is my config file (By the way it works very find for the incubator :
'application' => array(
'controllersDir' => __DIR__ . '/../../app/controllers/',
'modelsDir' => __DIR__ . '/../../app/models/',
'viewsDir' => __DIR__ . '/../../app/views/',
'pluginsDir' => __DIR__ . '/../../app/plugins/',
'libraryDir' => __DIR__ . '/../../app/library/',
'incubator' => __DIR__ . '/../../vendor/phalcon/incubator/Library/',
'googleAPI' => __DIR__ . '/../../vendor/google/src/'
),
This my code in the index.php :
$config = include(__DIR__ . "/../app/config/config.php");
$loader = new \Phalcon\Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(
array(
$config->application->incubator,
$config->application->controllersDir,
$config->application->modelsDir,
$config->application->pluginsDir,
$config->application->googleAPI,
))->register();
This the code where I try using it :
public function googleAction() {
$client = new Google_Client();
$client->setApplicationName("");
$client->setClientId('');
$client->setClientSecret('');
$client->setRedirectUri('');
//$client->setDeveloperKey('');
$oauth2 = new Google_Oauth2Service($client);
$code = $this->request->get('code');
if (isset($code)) {
$client->authenticate($code);
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
return;
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
/*if (isset($_REQUEST['logout'])) {
unset($_SESSION['token']);
$client->revokeToken();
}*/
if ($client->getAccessToken()) {
$user = $oauth2->userinfo->get();
// These fields are currently filtered through the PHP sanitize filters.
// See https://www.php.net/manual/en/filter.filters.sanitize.php
$email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);
$img = filter_var($user['picture'], FILTER_VALIDATE_URL);
$personMarkup = "$email<div><img src='$img?sz=50'></div>";
// The access token may have been updated lazily.
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
}
$this->response->redirect($authUrl, true);
}
Does someone have an idea or a solution ?
Thank you !