File indexing completed on 2024-05-12 06:02:39

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Gdata
0017  * @subpackage Analytics
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Gdata
0025  */
0026 // require_once 'Zend/Gdata.php';
0027 
0028 /**
0029  * @see Zend_Gdata_Analytics_AccountEntry
0030  */
0031 // require_once 'Zend/Gdata/Analytics/AccountEntry.php';
0032 
0033 /**
0034  * @see Zend_Gdata_Analytics_AccountFeed
0035  */
0036 // require_once 'Zend/Gdata/Analytics/AccountFeed.php';
0037 
0038 /**
0039  * @see Zend_Gdata_Analytics_DataEntry
0040  */
0041 // require_once 'Zend/Gdata/Analytics/DataEntry.php';
0042 
0043 /**
0044  * @see Zend_Gdata_Analytics_DataFeed
0045  */
0046 // require_once 'Zend/Gdata/Analytics/DataFeed.php';
0047 
0048 /**
0049  * @see Zend_Gdata_Analytics_DataQuery
0050  */
0051 // require_once 'Zend/Gdata/Analytics/DataQuery.php';
0052 
0053 /**
0054  * @see Zend_Gdata_Analytics_AccountQuery
0055  */
0056 // require_once 'Zend/Gdata/Analytics/AccountQuery.php';
0057 
0058 /**
0059  * @category   Zend
0060  * @package    Zend_Gdata
0061  * @subpackage Analytics
0062  */
0063 class Zend_Gdata_Analytics extends Zend_Gdata
0064 {
0065 
0066     const AUTH_SERVICE_NAME = 'analytics';
0067     const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/data';
0068     const ANALYTICS_ACCOUNT_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/management/accounts';
0069 
0070     public static $namespaces = array(
0071         array('analytics', 'http://schemas.google.com/analytics/2009', 1, 0),
0072         array('ga', 'http://schemas.google.com/ga/2009', 1, 0)
0073      );
0074 
0075     /**
0076      * Create Gdata object
0077      *
0078      * @param Zend_Http_Client $client
0079      * @param string $applicationId The identity of the app in the form of
0080      *          Company-AppName-Version
0081      */
0082     public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
0083     {
0084         $this->registerPackage('Zend_Gdata_Analytics');
0085         $this->registerPackage('Zend_Gdata_Analytics_Extension');
0086         parent::__construct($client, $applicationId);
0087         $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
0088     }
0089 
0090     /**
0091      * Retrieve account feed object
0092      * 
0093      * @param string|Zend_Uri_Uri $uri
0094      * @return Zend_Gdata_Analytics_AccountFeed
0095      */
0096     public function getAccountFeed($uri = self::ANALYTICS_ACCOUNT_FEED_URI)
0097     {
0098         if ($uri instanceof Query) {
0099             $uri = $uri->getQueryUrl();
0100         }
0101         return parent::getFeed($uri, 'Zend_Gdata_Analytics_AccountFeed');
0102     }
0103 
0104     /**
0105      * Retrieve data feed object
0106      * 
0107      * @param string|Zend_Uri_Uri $uri
0108      * @return Zend_Gdata_Analytics_DataFeed
0109      */
0110     public function getDataFeed($uri = self::ANALYTICS_FEED_URI)
0111     {
0112         if ($uri instanceof Query) {
0113             $uri = $uri->getQueryUrl();
0114         }
0115         return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed');
0116     }
0117 
0118     /**
0119      * Returns a new DataQuery object.
0120      * 
0121      * @return Zend_Gdata_Analytics_DataQuery
0122      */
0123     public function newDataQuery()
0124     {
0125         return new Zend_Gdata_Analytics_DataQuery();
0126     }
0127     
0128     /**
0129      * Returns a new AccountQuery object.
0130      *
0131      * @return Zend_Gdata_Analytics_AccountQuery
0132      */
0133     public function newAccountQuery()
0134     {
0135         return new Zend_Gdata_Analytics_AccountQuery();
0136     }
0137 }