|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Gdata |
|
17 * @subpackage Analytics |
|
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id$ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Gdata |
|
25 */ |
|
26 require_once 'Zend/Gdata.php'; |
|
27 |
|
28 /** |
|
29 * @see Zend_Gdata_Analytics_AccountEntry |
|
30 */ |
|
31 require_once 'Zend/Gdata/Analytics/AccountEntry.php'; |
|
32 |
|
33 /** |
|
34 * @see Zend_Gdata_Analytics_AccountFeed |
|
35 */ |
|
36 require_once 'Zend/Gdata/Analytics/AccountFeed.php'; |
|
37 |
|
38 /** |
|
39 * @see Zend_Gdata_Analytics_DataEntry |
|
40 */ |
|
41 require_once 'Zend/Gdata/Analytics/DataEntry.php'; |
|
42 |
|
43 /** |
|
44 * @see Zend_Gdata_Analytics_DataFeed |
|
45 */ |
|
46 require_once 'Zend/Gdata/Analytics/DataFeed.php'; |
|
47 |
|
48 /** |
|
49 * @see Zend_Gdata_Analytics_DataQuery |
|
50 */ |
|
51 require_once 'Zend/Gdata/Analytics/DataQuery.php'; |
|
52 |
|
53 /** |
|
54 * @see Zend_Gdata_Analytics_AccountQuery |
|
55 */ |
|
56 require_once 'Zend/Gdata/Analytics/AccountQuery.php'; |
|
57 |
|
58 /** |
|
59 * @category Zend |
|
60 * @package Zend_Gdata |
|
61 * @subpackage Analytics |
|
62 */ |
|
63 class Zend_Gdata_Analytics extends Zend_Gdata |
|
64 { |
|
65 |
|
66 const AUTH_SERVICE_NAME = 'analytics'; |
|
67 const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/data'; |
|
68 const ANALYTICS_ACCOUNT_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/management/accounts'; |
|
69 |
|
70 public static $namespaces = array( |
|
71 array('analytics', 'http://schemas.google.com/analytics/2009', 1, 0), |
|
72 array('ga', 'http://schemas.google.com/ga/2009', 1, 0) |
|
73 ); |
|
74 |
|
75 /** |
|
76 * Create Gdata object |
|
77 * |
|
78 * @param Zend_Http_Client $client |
|
79 * @param string $applicationId The identity of the app in the form of |
|
80 * Company-AppName-Version |
|
81 */ |
|
82 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') |
|
83 { |
|
84 $this->registerPackage('Zend_Gdata_Analytics'); |
|
85 $this->registerPackage('Zend_Gdata_Analytics_Extension'); |
|
86 parent::__construct($client, $applicationId); |
|
87 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME); |
|
88 } |
|
89 |
|
90 /** |
|
91 * Retrieve account feed object |
|
92 * |
|
93 * @param string|Zend_Uri_Uri $uri |
|
94 * @return Zend_Gdata_Analytics_AccountFeed |
|
95 */ |
|
96 public function getAccountFeed($uri = self::ANALYTICS_ACCOUNT_FEED_URI) |
|
97 { |
|
98 if ($uri instanceof Query) { |
|
99 $uri = $uri->getQueryUrl(); |
|
100 } |
|
101 return parent::getFeed($uri, 'Zend_Gdata_Analytics_AccountFeed'); |
|
102 } |
|
103 |
|
104 /** |
|
105 * Retrieve data feed object |
|
106 * |
|
107 * @param string|Zend_Uri_Uri $uri |
|
108 * @return Zend_Gdata_Analytics_DataFeed |
|
109 */ |
|
110 public function getDataFeed($uri = self::ANALYTICS_FEED_URI) |
|
111 { |
|
112 if ($uri instanceof Query) { |
|
113 $uri = $uri->getQueryUrl(); |
|
114 } |
|
115 return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed'); |
|
116 } |
|
117 |
|
118 /** |
|
119 * Returns a new DataQuery object. |
|
120 * |
|
121 * @return Zend_Gdata_Analytics_DataQuery |
|
122 */ |
|
123 public function newDataQuery() |
|
124 { |
|
125 return new Zend_Gdata_Analytics_DataQuery(); |
|
126 } |
|
127 |
|
128 /** |
|
129 * Returns a new AccountQuery object. |
|
130 * |
|
131 * @return Zend_Gdata_Analytics_AccountQuery |
|
132 */ |
|
133 public function newAccountQuery() |
|
134 { |
|
135 return new Zend_Gdata_Analytics_AccountQuery(); |
|
136 } |
|
137 } |