The Google API Client Library enables you to work with Google APIs such as Google+, Drive, or YouTube on your server with eZPublish4.x
eZPublish integration is still in beta and is in parallel development with [Google API](https://github.com/google/google-api-php-client)
http://developers.google.com/api-client-library/php
Enabled the extension in your site.ini
See the examples/ directory for examples of the key client features. You can view them in your browser by running the php built-in web server.
$ php -S localhost:8000 -t examples/
And then browsing to the host and port you specified
(in the above example, http://localhost:8000
).
<?php
$googleApiIni = \eZINI::instance('googleapi.ini');
$googleAnalyticsIni = \eZINI::instance('googleanalytics.ini');
$googleapi = new eZGoogleApi(
'oauth2',
array(
'application_name' => $googleAnalyticsIni->variable('GoogleAnalyticsSettings', 'ApplicationName'),
'scopes' => \Google_Service_Analytics::ANALYTICS_READONLY
)
);
// create service and get data
$service = eZGoogleAnalytics::getService($googleapi->client);
$service->setRessource('reportingcorega');
$service->setProfileID(PROFILEID);
$service->setPeriod(PERIODAFTERBEFORE, PERIODBEFORE);
$service->setParameter("max-results", 1000);
$service->getResults();