本文整理汇总了PHP中Piwik_API_Request类的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_API_Request类的具体用法?PHP Piwik_API_Request怎么用?PHP Piwik_API_Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Piwik_API_Request类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_callableApiMethods_doNotFail
function test_callableApiMethods_doNotFail()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik::createLogObject();
Piwik::createAccessObject();
Piwik::createDatabaseObject();
Piwik::setUserIsSuperUser();
Piwik_Translate::getInstance()->loadEnglishTranslation();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->loadPlugins(Piwik_Config::getInstance()->Plugins['Plugins']);
Piwik_SitesManager_API::getInstance()->addSite("name", "http://example.org");
$apiGenerator = new Piwik_API_DocumentationGenerator_CallAllMethods();
$requestUrls = $apiGenerator->getAllRequestsWithParameters();
$this->assertTrue(count($requestUrls) > 20);
foreach ($requestUrls as $url) {
$call = new Piwik_API_Request($url);
$output = $call->process();
// var_dump($url);
// var_dump($output);
$this->assertTrue(!empty($output));
}
Piwik_Translate::getInstance()->unloadEnglishTranslation();
$this->pass();
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:25,代码来源:DocumentationGenerator.test.php
示例2: addMainPageMetricsToReport
/**
* Add the main metrics (pageviews, exits, bounces) to the full report.
* Data is loaded from Actions.getPageUrls using the label filter.
*/
private function addMainPageMetricsToReport(&$report, $pageUrl, $idSite, $period, $date, $segment)
{
$label = Piwik_Actions::getActionExplodedNames($pageUrl, Piwik_Tracker_Action::TYPE_ACTION_URL);
if (count($label) == 1) {
$label = $label[0];
} else {
$label = array_map('urlencode', $label);
$label = implode('>', $label);
}
$parameters = array('method' => 'Actions.getPageUrls', 'idSite' => $idSite, 'period' => $period, 'date' => $date, 'label' => $label, 'format' => 'original', 'serialize' => '0', 'expanded' => '0');
if (!empty($segment)) {
$parameters['segment'] = $segment;
}
$url = Piwik_Url::getQueryStringFromParameters($parameters);
$request = new Piwik_API_Request($url);
try {
/** @var $dataTable Piwik_DataTable */
$dataTable = $request->process();
} catch (Exception $e) {
throw new Exception("Actions.getPageUrls returned an error: " . $e->getMessage() . "\n");
}
if ($dataTable->getRowsCount() == 0) {
throw new Exception("The label '{$label}' could not be found in Actions.getPageUrls\n");
}
$row = $dataTable->getFirstRow();
if ($row !== false) {
$report['pageMetrics'] = array('pageviews' => intval($row->getColumn('nb_hits')), 'exits' => intval($row->getColumn('exit_nb_visits')), 'bounces' => intval($row->getColumn('entry_bounce_count')));
} else {
$report['pageMetrics'] = array('pageviews' => 0, 'exits' => 0, 'bounces' => 0);
}
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:35,代码来源:API.php
示例3: worldMap
function worldMap()
{
if (!Piwik_PluginsManager::getInstance()->isPluginActivated('UserCountry')) {
return '';
}
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik::checkUserHasViewAccess($idSite);
$period = Piwik_Common::getRequestVar('period');
$date = Piwik_Common::getRequestVar('date');
$token_auth = Piwik::getCurrentUserTokenAuth();
$view = Piwik_View::factory('worldmap');
$view->dataUrl = "?module=API" . "&method=API.getProcessedReport&format=XML" . "&apiModule=UserCountry&apiAction=getCountry" . "&idSite=" . $idSite . "&period=" . $period . "&date=" . $date . "&token_auth=" . $token_auth . "&segment=" . Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('segment', '')) . "&filter_limit=-1";
// definition of the color scale
$view->hueMin = 218;
$view->hueMax = 216;
$view->satMin = "0.285";
$view->satMax = "0.9";
$view->lgtMin = ".97";
$view->lgtMax = ".44";
$request = new Piwik_API_Request('method=API.getMetadata&format=PHP' . '&apiModule=UserCountry&apiAction=getCountry' . '&idSite=' . $idSite . '&period=' . $period . '&date=' . $date . '&token_auth=' . $token_auth . '&filter_limit=-1');
$metaData = $request->process();
$metrics = array();
foreach ($metaData[0]['metrics'] as $id => $val) {
if (Piwik_Common::getRequestVar('period') == 'day' || $id != 'nb_uniq_visitors') {
$metrics[] = array($id, $val);
}
}
foreach ($metaData[0]['processedMetrics'] as $id => $val) {
$metrics[] = array($id, $val);
}
$view->metrics = $metrics;
$view->defaultMetric = 'nb_visits';
echo $view->render();
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:34,代码来源:Controller.php
示例4: index
function index()
{
$view = new Piwik_View('Goals/templates/overview.tpl');
$view->currency = Piwik::getCurrency();
$view->title = 'All goals - evolution';
$view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions')));
$view->nameGraphEvolution = 'GoalsgetEvolutionGraph';
// sparkline for the historical data of the above values
$view->urlSparklineConversions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions'))));
$view->urlSparklineConversionRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate'))));
$view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue'))));
$request = new Piwik_API_Request("method=Goals.get&format=original");
$datatable = $request->process();
$dataRow = $datatable->getFirstRow();
$view->nb_conversions = $dataRow->getColumn('Goal_nb_conversions');
$view->conversion_rate = $dataRow->getColumn('Goal_conversion_rate');
$view->revenue = $dataRow->getColumn('Goal_revenue');
$goalMetrics = array();
foreach ($this->goals as $idGoal => $goal) {
$goalMetrics[$idGoal] = $this->getMetricsForGoal($idGoal);
$goalMetrics[$idGoal]['name'] = $goal['name'];
}
$view->goalMetrics = $goalMetrics;
$view->goals = $this->goals;
$view->goalsJSON = json_encode($this->goals);
$view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
echo $view->render();
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:28,代码来源:Controller.php
示例5: _processRequest
function _processRequest($request)
{
$token_auth = self::_getToken();
$request = new Piwik_API_Request($request . "&format=php&token_auth=" . $token_auth);
$result = $request->process();
$content = unserialize($result);
return $content;
}
开发者ID:Doluci,项目名称:tomatocart,代码行数:8,代码来源:piwik.php
示例6: getVisits
static public function getVisits()
{
$requestString = "method=VisitsSummary.getVisits".
"&format=original".
"&disable_generic_filters=1";
$request = new Piwik_API_Request($requestString);
return $request->process();
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:8,代码来源:Controller.php
示例7: index
function index()
{
// when calling the API through http, we limit the number of returned results
if (!isset($_GET['filter_limit'])) {
$_GET['filter_limit'] = Zend_Registry::get('config')->General->API_datatable_default_limit;
}
$request = new Piwik_API_Request('token_auth=' . Piwik_Common::getRequestVar('token_auth', 'anonymous', 'string'));
echo $request->process();
}
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:9,代码来源:Controller.php
示例8: getLastVisitsStart
public function getLastVisitsStart($fetch = false)
{
// hack, ensure we load today's visits by default
$_GET['date'] = 'today';
$_GET['period'] = 'day';
$view = Piwik_View::factory('lastVisits');
$view->idSite = $this->idSite;
$api = new Piwik_API_Request("method=Live.getLastVisitsDetails&idSite={$this->idSite}&filter_limit=10&format=php&serialize=0&disable_generic_filters=1");
$visitors = $api->process();
$view->visitors = $visitors;
return $this->render($view, $fetch);
}
开发者ID:Gninety,项目名称:Microweber,代码行数:12,代码来源:Controller.php
示例9: renderSidebar
/** Render the area left of the iframe */
public function renderSidebar()
{
$idSite = Piwik_Common::getRequestVar('idSite');
$period = Piwik_Common::getRequestVar('period');
$date = Piwik_Common::getRequestVar('date');
$currentUrl = Piwik_Common::getRequestVar('currentUrl');
$currentUrl = Piwik_Common::unsanitizeInputValue($currentUrl);
$normalizedCurrentUrl = Piwik_Tracker_Action::excludeQueryParametersFromUrl($currentUrl, $idSite);
$normalizedCurrentUrl = Piwik_Common::unsanitizeInputValue($normalizedCurrentUrl);
// load the appropriate row of the page urls report using the label filter
Piwik_Actions_ArchivingHelper::reloadConfig();
$path = Piwik_Actions_ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Piwik_Tracker_Action::TYPE_ACTION_URL);
$path = array_map('urlencode', $path);
$label = implode('>', $path);
$request = new Piwik_API_Request('method=Actions.getPageUrls' . '&idSite=' . urlencode($idSite) . '&date=' . urlencode($date) . '&period=' . urlencode($period) . '&label=' . urlencode($label) . '&format=original');
$dataTable = $request->process();
$data = array();
if ($dataTable->getRowsCount() > 0) {
$row = $dataTable->getFirstRow();
$translations = Piwik_API_API::getDefaultMetricTranslations();
$showMetrics = array('nb_hits', 'nb_visits', 'nb_uniq_visitors', 'bounce_rate', 'exit_rate', 'avg_time_on_page');
foreach ($showMetrics as $metric) {
$value = $row->getColumn($metric);
if ($value === false) {
// skip unique visitors for period != day
continue;
}
if ($metric == 'avg_time_on_page') {
$value = Piwik::getPrettyTimeFromSeconds($value);
}
$data[] = array('name' => $translations[$metric], 'value' => $value);
}
}
// generate page url string
foreach ($path as &$part) {
$part = preg_replace(';^/;', '', urldecode($part));
}
$page = '/' . implode('/', $path);
$page = preg_replace(';/index$;', '/', $page);
if ($page == '/') {
$page = '/index';
}
// render template
$view = Piwik_View::factory('sidebar');
$view->data = $data;
$view->location = $page;
$view->normalizedUrl = $normalizedCurrentUrl;
$view->label = $label;
$view->idSite = $idSite;
$view->period = $period;
$view->date = $date;
echo $view->render();
}
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:54,代码来源:Controller.php
示例10: buildView
protected function buildView()
{
// access control
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik_API_Request::reloadAuthUsingTokenAuth();
if (!Piwik::isUserHasViewAccess($idSite)) {
throw new Exception(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idSite)));
}
// collect data
$this->parametersToModify['action'] = $this->currentControllerAction;
$this->parametersToModify = array_merge($this->variablesDefault, $this->parametersToModify);
$this->graphData = $this->getGraphData();
// build view
$view = new Piwik_View($this->dataTableTemplate);
$view->width = $this->width;
$view->height = $this->height;
$view->chartDivId = $this->getUniqueIdViewDataTable() . "Chart";
$view->graphType = $this->graphType;
$view->data = $this->graphData;
$view->isDataAvailable = strpos($this->graphData, '"series":[]') === false;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
$view->properties = $this->getViewProperties();
$view->reportDocumentation = $this->getReportDocumentation();
return $view;
}
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:25,代码来源:GenerateGraphHTML.php
示例11: buildView
protected function buildView()
{
$view = new Piwik_View($this->dataTableTemplate);
$this->uniqueIdViewDataTable = $this->getUniqueIdViewDataTable();
$view->graphType = $this->graphType;
$this->chartDivId = $this->uniqueIdViewDataTable . "Chart_swf";
$this->parametersToModify['action'] = $this->currentControllerAction;
$this->parametersToModify = array_merge($this->variablesDefault, $this->parametersToModify);
$url = Piwik_Url::getCurrentQueryStringWithParametersModified($this->parametersToModify);
$this->includeData = !Zend_Registry::get('config')->Debug->disable_merged_requests;
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik_API_Request::reloadAuthUsingTokenAuth();
if (!Piwik::isUserHasViewAccess($idSite)) {
throw new Exception(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idSite)));
}
if ($this->includeData) {
$this->chartData = $this->getFlashData();
} else {
$this->chartData = null;
}
$view->flashParameters = $this->getFlashParameters();
$view->urlGraphData = $url;
$view->chartDivId = $this->chartDivId;
$view->formEmbedId = "formEmbed" . $this->uniqueIdViewDataTable;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
$view->properties = $this->getViewProperties();
return $view;
}
开发者ID:Gninety,项目名称:Microweber,代码行数:28,代码来源:GenerateGraphHTML.php
示例12: getLastVisits
function getLastVisits($fetch = false)
{
$idSite = Piwik_Common::getRequestVar('idSite', null, 'int');
$minIdVisit = Piwik_Common::getRequestVar('minIdVisit', 0, 'int');
$limit = 10;
$api = new Piwik_API_Request("method=Live.getLastVisits&idSite={$idSite}&limit={$limit}&minIdVisit={$minIdVisit}&format=php&serialize=0&disable_generic_filters=1");
$view = new Piwik_View('Live/templates/lastVisits.tpl');
$visitors = $api->process();
if ($minIdVisit == 0) {
$visitors = array_slice($visitors, 3);
}
$view->visitors = $visitors;
$rendered = $view->render($fetch);
if ($fetch) {
return $rendered;
}
echo $rendered;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:18,代码来源:Controller.php
示例13: oneClickResults
public function oneClickResults()
{
Piwik_API_Request::reloadAuthUsingTokenAuth($_POST);
Piwik::checkUserIsSuperUser();
$view = Piwik_View::factory('update_one_click_results');
$view->coreError = Piwik_Common::getRequestVar('error', '', 'string', $_POST);
$view->feedbackMessages = safe_unserialize(Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('messages', '', 'string', $_POST)));
echo $view->render();
}
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:9,代码来源:Controller.php
示例14: testAnotherApi
/**
* @depends testApi
* @dataProvider getAnotherApiForTesting
* @group Integration
* @group VisitsInPast_InvalidateOldReports
*/
public function testAnotherApi($api, $params)
{
// 1) Invalidate old reports for the 2 websites
// Test invalidate 1 date only
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=4,5,6,55,-1,s',1&dates=2010-01-03");
$r->process();
// Test invalidate comma separated dates
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . self::$idSite . "," . self::$idSite2 . "&dates=2010-01-06,2009-10-30");
$r->process();
// test invalidate date in the past
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . self::$idSite2 . "&dates=2009-06-29");
$r->process();
// invalidate a date more recent to check the date is only updated when it's earlier than current
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . self::$idSite2 . "&dates=2010-03-03");
$r->process();
// 2) Call API again, with an older date, which should now return data
$this->runApiTests($api, $params);
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:24,代码来源:VisitsInPast_InvalidateOldReportsTest.php
示例15: test_callableApiMethods_doNotFail
function test_callableApiMethods_doNotFail()
{
Piwik::createConfigObject();
Piwik::createLogObject();
Piwik::createAccessObject();
Piwik::createDatabaseObject();
Piwik::setUserIsSuperUser();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
$apiGenerator = new Piwik_API_DocumentationGenerator_CallAllMethods();
$requestUrls = $apiGenerator->getAllRequestsWithParameters();
$this->assertTrue(count($requestUrls) > 20);
foreach ($requestUrls as $url) {
$call = new Piwik_API_Request($url);
$output = $call->process();
// var_dump($url);
// var_dump($output);
$this->assertTrue(!empty($output));
}
$this->pass();
}
开发者ID:klando,项目名称:pgpiwik,代码行数:21,代码来源:DocumentationGenerator.test.php
示例16: getAnotherApiToTest
/**
* This is called after getApiToTest()
* WE invalidate old reports and check that data is now returned for old dates
*/
public function getAnotherApiToTest()
{
// 1) Invalidate old reports for the 2 websites
// Test invalidate 1 date only
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports\n\t\t\t&idSites=4,5,6,55,-1,s',1&dates=2010-01-03");
$r->process();
// Test invalidate comma separated dates
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports\n\t\t\t&idSites=" . $this->idSite . "," . $this->idSite2 . "&dates=2010-01-06,2009-10-30");
$r->process();
// test invalidate date in the past
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports\n\t\t\t&idSites=" . $this->idSite2 . "&dates=2009-06-29");
$r->process();
// invalidate a date more recent to check the date is only updated when it's earlier than current
$r = new Piwik_API_Request("module=API&method=CoreAdminHome.invalidateArchivedReports\n\t\t\t&idSites=" . $this->idSite2 . "&dates=2010-03-03");
$r->process();
// 2) Call API again, with an older date, which should now return data
// website 1
$this->tests[0][1]['testSuffix'] = 'Website' . $this->idSite . '_OldReportsShouldAppear';
// website2
$this->tests[1][1]['testSuffix'] = 'Website' . $this->idSite2 . '_OldReportsShouldAppear';
return $this->tests;
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:26,代码来源:VisitsInPast_InvalidateOldReports.test.php
示例17: iframe
function iframe()
{
Piwik_API_Request::reloadAuthUsingTokenAuth();
$this->init();
$controllerName = Piwik_Common::getRequestVar('moduleToWidgetize');
$actionName = Piwik_Common::getRequestVar('actionToWidgetize');
$parameters = array ( $fetch = true );
$outputDataTable = Piwik_FrontController::getInstance()->fetchDispatch( $controllerName, $actionName, $parameters);
$view = Piwik_View::factory('iframe');
$this->setGeneralVariablesView($view);
$view->content = $outputDataTable;
echo $view->render();
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:13,代码来源:Controller.php
示例18: postDataTableLoadedFromAPI
/**
* Hook called after the dataTable has been loaded from the API
* Can be used to add, delete or modify the data freshly loaded
*/
protected function postDataTableLoadedFromAPI()
{
if (empty($this->dataTable)) {
return false;
}
// First, filters that delete rows
foreach ($this->queuedFiltersPriority as $filter) {
$filterName = $filter[0];
$filterParameters = $filter[1];
$this->dataTable->filter($filterName, $filterParameters);
}
if (0 == Piwik_Common::getRequestVar('disable_generic_filters', '0', 'string')) {
// Second, generic filters (Sort, Limit, Replace Column Names, etc.)
$requestString = $this->getRequestString();
$request = Piwik_API_Request::getRequestArrayFromString($requestString);
if (!empty($this->variablesDefault['enable_sort']) && $this->variablesDefault['enable_sort'] === 'false') {
$request['filter_sort_column'] = $request['filter_sort_order'] = '';
}
$genericFilter = new Piwik_API_DataTableGenericFilter($request);
$genericFilter->filter($this->dataTable);
}
// Finally, apply datatable filters that were queued (should be 'presentation' filters that do not affect the number of rows)
foreach ($this->queuedFilters as $filter) {
$filterName = $filter[0];
$filterParameters = $filter[1];
$this->dataTable->filter($filterName, $filterParameters);
}
}
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:32,代码来源:ViewDataTable.php
示例19: getNumericValue
/**
* Returns a numeric value from the API.
* Works only for API methods that originally returns numeric values (there is no cast here)
*
* @param string $methodToCall Name of method to call, eg. Referers.getNumberOfDistinctSearchEngines
* @return int|float
*/
protected function getNumericValue($methodToCall)
{
$requestString = 'method=' . $methodToCall . '&format=original';
$request = new Piwik_API_Request($requestString);
return $request->process();
}
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:13,代码来源:Controller.php
示例20: loadRowEvolutionData
/** @return Piwik_DataTable_Array */
private function loadRowEvolutionData($idSite, $period, $date, $apiModule, $apiAction, $label, $segment)
{
if ($period == 'range') {
// load days in the range
$period = 'day';
}
$parameters = array('method' => $apiModule . '.' . $apiAction, 'label' => $label, 'idSite' => $idSite, 'period' => $period, 'date' => $date, 'format' => 'original', 'serialize' => '0', 'segment' => $segment);
// add "processed metrics" like actions per visit or bounce rate
if ($apiModule != 'Actions') {
$parameters['filter_add_columns_when_show_all_columns'] = '1';
}
$url = Piwik_Url::getQueryStringFromParameters($parameters);
$request = new Piwik_API_Request($url);
try {
$dataTable = $request->process();
} catch (Exception $e) {
throw new Exception("API returned an error: " . $e->getMessage() . "\n");
}
if (!$dataTable instanceof Piwik_DataTable_Array) {
throw new Exception("API didn't return a DataTable array. Maybe you used " . "a single date (i.e. not YYYY-MM-DD,YYYY-MM-DD)");
}
return $dataTable;
}
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:24,代码来源:API.php
注:本文中的Piwik_API_Request类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论