本文整理汇总了PHP中gapi::getTotalResults方法的典型用法代码示例。如果您正苦于以下问题:PHP gapi::getTotalResults方法的具体用法?PHP gapi::getTotalResults怎么用?PHP gapi::getTotalResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gapi
的用法示例。
在下文中一共展示了gapi::getTotalResults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _monthPageViewsVisits
/**
* A temporary function to hold the first example of a chart data return.
* We can make this more robust and to handle more uses cases.
* @todo Make an entire analytics plugin to be part of the reports plugin.
*/
public function _monthPageViewsVisits()
{
if (!empty($instance) && defined('__REPORTS_ANALYTICS_' . $instance)) {
extract(unserialize(constant('__REPORTS_ANALYTICS_' . $instance)));
} else {
if (defined('__REPORTS_ANALYTICS')) {
extract(unserialize(__REPORTS_ANALYTICS));
}
}
if (!empty($userName) && !empty($password) && !empty($setAccount)) {
App::import('Vendor', 'Reports.gapi');
$ga = new gapi($userName, $password, isset($_SESSION['ga_auth_token']) ? $_SESSION['ga_auth_token'] : null);
$_SESSION['ga_auth_token'] = $ga->getAuthToken();
// $filter = 'country == United States && browser == Firefox || browser == Chrome';
// $report_id, $dimensions, $metrics, $sort_metric=null, $filter=null, $start_date=null, $end_date=null, $start_index=1, $max_results=30
// http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html#ga:visitors
foreach ($ga->requestAccountData() as $account) {
if (is_object($account)) {
if ($account->properties['webPropertyId'] == $setAccount) {
$reportId = $account->properties['profileId'];
}
}
}
$backMonth = date('Y-m-d', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
$ga->requestReportData(53475, array('date'), array('pageviews', 'visits'), 'date', null, $backMonth, date('Y-m-d'));
$i = 0;
foreach ($ga->getResults() as $result) {
#debug($result);
$chartData[$i]['pageviews'] = $result->getPageviews();
$chartData[$i]['visits'] = $result->getVisits();
$chartData[$i]['date'] = $result->getDate();
$i++;
}
$chartData['totalResults'] = $ga->getTotalResults();
$chartData['totalPageViews'] = $ga->getPageviews();
$chartData['totalVisits'] = $ga->getVisits();
$chartData['updated'] = $ga->getUpdated();
return $chartData;
} else {
// google analytics username and password must be set in settings (__REPORTS_ANALYTICS)
return;
}
}
示例2:
</td>
<td><?php
echo $result->getVisits();
?>
</td>
</tr>
<?php
}
?>
</table>
<table>
<tr>
<th>Total Results</th>
<td><?php
echo $ga->getTotalResults();
?>
</td>
</tr>
<tr>
<th>Total Pageviews</th>
<td><?php
echo $ga->getPageviews();
?>
</tr>
<tr>
<th>Total Visits</th>
<td><?php
echo $ga->getVisits();
?>
</td>