Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
Merge with changes submitted to the ZF1 svn repository
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmitd committed Sep 20, 2012
1 parent 75d2bc7 commit eff55a7
Show file tree
Hide file tree
Showing 13 changed files with 1,184 additions and 731 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ An additonal Zend_GData component to query data from Analytics.
/** … **/
}

More on the [blog](http://healthycod.in/2011/07/google-analytics-and-zend-framework).
More on the [blog](http://healthycod.in/2011/07/google-analytics-and-zend-framework). Also take a look in the [ZF1-Framework](http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Gdata/Analytics/).
238 changes: 137 additions & 101 deletions Zend/Gdata/Analytics.php
Original file line number Diff line number Diff line change
@@ -1,101 +1,137 @@
<?php
/**
* @see Zend_Gdata
*/
require_once 'Zend/Gdata.php';

/**
* @see Zend_Gdata_Analytics_AccountEntry
*/
require_once 'Zend/Gdata/Analytics/AccountEntry.php';

/**
* @see Zend_Gdata_Analytics_AccountFeed
*/
require_once 'Zend/Gdata/Analytics/AccountFeed.php';

/**
* @see Zend_Gdata_Analytics_DataEntry
*/
require_once 'Zend/Gdata/Analytics/DataEntry.php';

/**
* @see Zend_Gdata_Analytics_DataFeed
*/
require_once 'Zend/Gdata/Analytics/DataFeed.php';

/**
* @see Zend_Gdata_Analytics_DataQuery
*/
require_once 'Zend/Gdata/Analytics/DataQuery.php';

/**
* @category Zend
* @package Zend_Gdata
* @subpackage Analytics
*/
class Zend_Gdata_Analytics extends Zend_Gdata
{

const AUTH_SERVICE_NAME = 'analytics';
const ANALYTICS_FEED_URI = 'https://www.google.com/analytics/feeds';
const ANALYTICS_ACCOUNT_FEED_URI = 'https://www.google.com/analytics/feeds/accounts';

public static $namespaces = array(
array('ga', 'http://schemas.google.com/analytics/2009', 1, 0)
);

/**
* Create Zend_Gdata_Analytics object
*
* @param Zend_Http_Client $client (optional) The HTTP client to use when
* when communicating with the Google Apps servers.
* @param string $applicationId The identity of the app in the form of Company-AppName-Version
*/
public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
{
$this->registerPackage('Zend_Gdata_Analytics');
$this->registerPackage('Zend_Gdata_Analytics_Extension');
parent::__construct($client, $applicationId);
$this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
}

/**
* Retrieve account feed object
*
* @return Zend_Gdata_Analytics_AccountFeed
*/
public function getAccountFeed()
{
$uri = self::ANALYTICS_ACCOUNT_FEED_URI . '/default?prettyprint=true';
return parent::getFeed($uri, 'Zend_Gdata_Analytics_AccountFeed');
}

/**
* Retrieve data feed object
*
* @param mixed $location
* @return Zend_Gdata_Analytics_DataFeed
*/
public function getDataFeed($location)
{
if ($location == null) {
$uri = self::ANALYTICS_FEED_URI;
} elseif ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed');
}

/**
* Returns a new DataQuery object.
*
* @return Zend_Gdata_Analytics_DataQuery
*/
public function newDataQuery($profileId=null)
{
return new Zend_Gdata_Analytics_DataQuery($profileId);
}
}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Gdata
* @subpackage Analytics
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
* @see Zend_Gdata
*/
require_once 'Zend/Gdata.php';

/**
* @see Zend_Gdata_Analytics_AccountEntry
*/
require_once 'Zend/Gdata/Analytics/AccountEntry.php';

/**
* @see Zend_Gdata_Analytics_AccountFeed
*/
require_once 'Zend/Gdata/Analytics/AccountFeed.php';

/**
* @see Zend_Gdata_Analytics_DataEntry
*/
require_once 'Zend/Gdata/Analytics/DataEntry.php';

/**
* @see Zend_Gdata_Analytics_DataFeed
*/
require_once 'Zend/Gdata/Analytics/DataFeed.php';

/**
* @see Zend_Gdata_Analytics_DataQuery
*/
require_once 'Zend/Gdata/Analytics/DataQuery.php';

/**
* @see Zend_Gdata_Analytics_AccountQuery
*/
require_once 'Zend/Gdata/Analytics/AccountQuery.php';

/**
* @category Zend
* @package Zend_Gdata
* @subpackage Analytics
*/
class Zend_Gdata_Analytics extends Zend_Gdata
{

const AUTH_SERVICE_NAME = 'analytics';
const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/data';
const ANALYTICS_ACCOUNT_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/management/accounts';

public static $namespaces = array(
array('analytics', 'http://schemas.google.com/analytics/2009', 1, 0),
array('ga', 'http://schemas.google.com/ga/2009', 1, 0)
);

/**
* Create Gdata object
*
* @param Zend_Http_Client $client
* @param string $applicationId The identity of the app in the form of
* Company-AppName-Version
*/
public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
{
$this->registerPackage('Zend_Gdata_Analytics');
$this->registerPackage('Zend_Gdata_Analytics_Extension');
parent::__construct($client, $applicationId);
$this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
}

/**
* Retrieve account feed object
*
* @param string|Zend_Uri_Uri $uri
* @return Zend_Gdata_Analytics_AccountFeed
*/
public function getAccountFeed($uri = self::ANALYTICS_ACCOUNT_FEED_URI)
{
if ($uri instanceof Query) {
$uri = $uri->getQueryUrl();
}
return parent::getFeed($uri, 'Zend_Gdata_Analytics_AccountFeed');
}

/**
* Retrieve data feed object
*
* @param string|Zend_Uri_Uri $uri
* @return Zend_Gdata_Analytics_DataFeed
*/
public function getDataFeed($uri = self::ANALYTICS_FEED_URI)
{
if ($uri instanceof Query) {
$uri = $uri->getQueryUrl();
}
return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed');
}

/**
* Returns a new DataQuery object.
*
* @return Zend_Gdata_Analytics_DataQuery
*/
public function newDataQuery()
{
return new Zend_Gdata_Analytics_DataQuery();
}

/**
* Returns a new AccountQuery object.
*
* @return Zend_Gdata_Analytics_AccountQuery
*/
public function newAccountQuery()
{
return new Zend_Gdata_Analytics_AccountQuery();
}
}
Loading

0 comments on commit eff55a7

Please sign in to comment.