当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::process方法代码示例

本文整理汇总了PHP中Piwik\API\Request::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::process方法的具体用法?PHP Request::process怎么用?PHP Request::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\API\Request的用法示例。


在下文中一共展示了Request::process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAnotherApi

 /**
  * @depends      testApi
  * @dataProvider getAnotherApiForTesting
  */
 public function testAnotherApi($api, $params)
 {
     $idSite = self::$fixture->idSite;
     $idSite2 = self::$fixture->idSite2;
     // 1) Invalidate old reports for the 2 websites
     // Test invalidate 1 date only
     $r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=4,5,6,55,-1,s',1&dates=2010-01-03");
     $this->assertApiResponseHasNoError($r->process());
     // Test invalidate comma separated dates
     $r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite . "," . $idSite2 . "&dates=2010-01-06,2009-10-30");
     $this->assertApiResponseHasNoError($r->process());
     // test invalidate date in the past
     // Format=original will re-throw exception
     $r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite2 . "&dates=2009-06-29&format=original");
     $this->assertApiResponseHasNoError($r->process());
     // invalidate a date more recent to check the date is only updated when it's earlier than current
     $r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSite2 . "&dates=2010-03-03");
     $this->assertApiResponseHasNoError($r->process());
     // Make an invalid call
     $idSiteNoAccess = 777;
     try {
         $request = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . $idSiteNoAccess . "&dates=2010-03-03&format=original");
         $request->process();
         $this->fail();
     } catch (Exception $e) {
     }
     // 2) Call API again, with an older date, which should now return data
     $this->runApiTests($api, $params);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:33,代码来源:VisitsInPastInvalidateOldReportsTest.php

示例2: renderSidebar

 /** Render the area left of the iframe */
 public function renderSidebar()
 {
     $idSite = Common::getRequestVar('idSite');
     $period = Common::getRequestVar('period');
     $date = Common::getRequestVar('date');
     $currentUrl = Common::getRequestVar('currentUrl');
     $currentUrl = Common::unsanitizeInputValue($currentUrl);
     $normalizedCurrentUrl = PageUrl::excludeQueryParametersFromUrl($currentUrl, $idSite);
     $normalizedCurrentUrl = Common::unsanitizeInputValue($normalizedCurrentUrl);
     // load the appropriate row of the page urls report using the label filter
     ArchivingHelper::reloadConfig();
     $path = ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Action::TYPE_PAGE_URL);
     $path = array_map('urlencode', $path);
     $label = implode('>', $path);
     $request = new Request('method=Actions.getPageUrls' . '&idSite=' . urlencode($idSite) . '&date=' . urlencode($date) . '&period=' . urlencode($period) . '&label=' . urlencode($label) . '&format=original' . '&format_metrics=0');
     $dataTable = $request->process();
     $formatter = new Metrics\Formatter\Html();
     $data = array();
     if ($dataTable->getRowsCount() > 0) {
         $row = $dataTable->getFirstRow();
         $translations = Metrics::getDefaultMetricTranslations();
         $showMetrics = array('nb_hits', 'nb_visits', 'nb_users', '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 == 'bounce_rate' || $metric == 'exit_rate') {
                 $value = $formatter->getPrettyPercentFromQuotient($value);
             } else {
                 if ($metric == 'avg_time_on_page') {
                     $value = $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
                 }
             }
             $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 = new View('@Overlay/renderSidebar');
     $view->data = $data;
     $view->location = $page;
     $view->normalizedUrl = $normalizedCurrentUrl;
     $view->label = $label;
     $view->idSite = $idSite;
     $view->period = $period;
     $view->date = $date;
     $this->outputCORSHeaders();
     return $view->render();
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:60,代码来源:Controller.php

示例3: loadFromApi

 public static function loadFromApi($params, $requestUrl)
 {
     $testRequest = new Request($requestUrl);
     // Cast as string is important. For example when calling
     // with format=original, objects or php arrays can be returned.
     $response = (string) $testRequest->process();
     return new Response($response, $params, $requestUrl);
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:8,代码来源:Response.php

示例4: loadFromApi

 public static function loadFromApi($params, $requestUrl)
 {
     $testRequest = new Request($requestUrl);
     // Cast as string is important. For example when calling
     // with format=original, objects or php arrays can be returned.
     // we also hide errors to prevent the 'headers already sent' in the ResponseBuilder (which sends Excel headers multiple times eg.)
     $response = (string) $testRequest->process();
     return new TestRequestResponse($response, $params, $requestUrl);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:9,代码来源:TestRequestResponse.php

示例5: index

 function index()
 {
     // when calling the API through http, we limit the number of returned results
     if (!isset($_GET['filter_limit'])) {
         $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit'];
     }
     $request = new Request('token_auth=' . Common::getRequestVar('token_auth', 'anonymous', 'string'));
     return $request->process();
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:9,代码来源:Controller.php

示例6: loadDataTableFromAPI

 /**
  * Function called by the ViewDataTable objects in order to fetch data from the API.
  * The function init() must have been called before, so that the object knows which API module and action to call.
  * It builds the API request string and uses Request to call the API.
  * The requested DataTable object is stored in $this->dataTable.
  */
 public function loadDataTableFromAPI()
 {
     // we build the request (URL) to call the API
     $requestArray = $this->getRequestArray();
     // we make the request to the API
     $request = new ApiRequest($requestArray);
     // and get the DataTable structure
     $dataTable = $request->process();
     return $dataTable;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:16,代码来源:Request.php

示例7: test_process_shouldKeepSuperUserPermission_IfAccessWasManuallySet

 public function test_process_shouldKeepSuperUserPermission_IfAccessWasManuallySet()
 {
     $this->access->setSuperUserAccess(true);
     $this->assertAccessReloadedAndRestored('difFenrenT');
     $request = new Request(array('method' => 'API.getPiwikVersion', 'token_auth' => 'difFenrenT'));
     $request->process();
     // make sure token auth was restored after it was loaded with difFenrenT
     $this->assertSameUserAsBeforeIsAuthenticated();
     $this->assertTrue($this->access->hasSuperUserAccess());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:10,代码来源:RequestTest.php

示例8: loadDataTableFromAPI

 /**
  * Function called by the ViewDataTable objects in order to fetch data from the API.
  * The function init() must have been called before, so that the object knows which API module and action to call.
  * It builds the API request string and uses Request to call the API.
  * The requested DataTable object is stored in $this->dataTable.
  */
 public function loadDataTableFromAPI($fixedRequestParams = array())
 {
     // we build the request (URL) to call the API
     $requestArray = $this->getRequestArray();
     foreach ($fixedRequestParams as $key => $value) {
         $requestArray[$key] = $value;
     }
     // we make the request to the API
     $request = new ApiRequest($requestArray);
     // and get the DataTable structure
     $dataTable = $request->process();
     return $dataTable;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:19,代码来源:Request.php

示例9: getLastVisitsStart

 public function getLastVisitsStart()
 {
     // hack, ensure we load today's visits by default
     $_GET['date'] = 'today';
     \Piwik\Period\Factory::checkPeriodIsEnabled('day');
     $_GET['period'] = 'day';
     $view = new View('@Live/getLastVisitsStart');
     $view->idSite = $this->idSite;
     $api = new 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);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:13,代码来源:Controller.php

示例10: requestReport

 public function requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment)
 {
     $report = $this->getReportByUniqueId($idSite, $reportUniqueId);
     $params = array('method' => $report['module'] . '.' . $report['action'], 'format' => 'original', 'idSite' => $idSite, 'period' => $period, 'date' => $date, 'filter_limit' => 1000, 'showColumns' => $metric);
     if (!empty($segment)) {
         $params['segment'] = $segment;
     }
     if (!empty($report['parameters']) && is_array($report['parameters'])) {
         $params = array_merge($params, $report['parameters']);
     }
     $request = new ApiRequest($params);
     $table = $request->process();
     return $table;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:14,代码来源:Model.php

示例11: index

 function index()
 {
     $token = 'token_auth=' . Common::getRequestVar('token_auth', 'anonymous', 'string');
     // when calling the API through http, we limit the number of returned results
     if (!isset($_GET['filter_limit'])) {
         $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit'];
         $token .= '&api_datatable_default_limit=' . $_GET['filter_limit'];
     }
     $request = new Request($token);
     $response = $request->process();
     if (is_array($response)) {
         $response = var_export($response, true);
     }
     return $response;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:15,代码来源:Controller.php

示例12: beforeRender

 public function beforeRender()
 {
     if ($this->requestConfig->idSubtable && $this->config->show_embedded_subtable) {
         $this->config->show_visualization_only = true;
     }
     // we do not want to get a datatable\map
     $period = Common::getRequestVar('period', 'day', 'string');
     if (Period\Range::parseDateRange($period)) {
         $period = 'range';
     }
     if ($this->dataTable->getRowsCount()) {
         $request = new ApiRequest(array('method' => 'API.get', 'module' => 'API', 'action' => 'get', 'format' => 'original', 'filter_limit' => '-1', 'disable_generic_filters' => 1, 'expanded' => 0, 'flat' => 0, 'filter_offset' => 0, 'period' => $period, 'showColumns' => implode(',', $this->config->columns_to_display), 'columns' => implode(',', $this->config->columns_to_display), 'pivotBy' => ''));
         $dataTable = $request->process();
         $this->assignTemplateVar('siteSummary', $dataTable);
     }
 }
开发者ID:igorclark,项目名称:piwik,代码行数:16,代码来源:HtmlTable.php

示例13: testAnotherApi

 /**
  * @depends      testApi
  * @dataProvider getAnotherApiForTesting
  * @group        Integration
  */
 public function testAnotherApi($api, $params)
 {
     // Get the top segment value
     $request = new Request('method=API.getSuggestedValuesForSegment' . '&segmentName=' . $params['segmentToComplete'] . '&idSite=' . $params['idSite'] . '&format=php&serialize=0');
     $response = $request->process();
     $this->checkRequestResponse($response);
     $topSegmentValue = @$response[0];
     if ($topSegmentValue !== false && !is_null($topSegmentValue)) {
         // Now build the segment request
         $segmentValue = rawurlencode(html_entity_decode($topSegmentValue));
         $params['segment'] = $params['segmentToComplete'] . '==' . $segmentValue;
         unset($params['segmentToComplete']);
         $this->runApiTests($api, $params);
         self::$processed++;
     } else {
         self::$skipped[] = $params['segmentToComplete'];
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:23,代码来源:AutoSuggestAPITest.php

示例14: testAnotherApi

 /**
  * @depends      testApi
  * @dataProvider getAnotherApiForTesting
  */
 public function testAnotherApi($api, $params)
 {
     // Get the top segment value
     $request = new Request('method=API.getSuggestedValuesForSegment' . '&segmentName=' . $params['segmentToComplete'] . '&idSite=' . $params['idSite'] . '&format=php&serialize=0');
     $response = $request->process();
     $this->assertApiResponseHasNoError($response);
     $topSegmentValue = @$response[0];
     if ($topSegmentValue !== false && !is_null($topSegmentValue)) {
         if (is_numeric($topSegmentValue) || is_float($topSegmentValue) || preg_match('/^\\d*?,\\d*$/', $topSegmentValue)) {
             $topSegmentValue = Common::forceDotAsSeparatorForDecimalPoint($topSegmentValue);
         }
         // Now build the segment request
         $segmentValue = rawurlencode(html_entity_decode($topSegmentValue));
         $params['segment'] = $params['segmentToComplete'] . '==' . $segmentValue;
         unset($params['segmentToComplete']);
         $this->runApiTests($api, $params);
         self::$processed++;
     } else {
         self::$skipped[] = $params['segmentToComplete'];
     }
 }
开发者ID:ahdinosaur,项目名称:analytics.dinosaur.is,代码行数:25,代码来源:AutoSuggestAPITest.php

示例15: getMetricsForGoal

 protected function getMetricsForGoal($idGoal)
 {
     $request = new Request("method=Goals.get&format=original&idGoal={$idGoal}");
     $datatable = $request->process();
     $dataRow = $datatable->getFirstRow();
     $nbConversions = $dataRow->getColumn('nb_conversions');
     $nbVisitsConverted = $dataRow->getColumn('nb_visits_converted');
     // Backward compatibilty before 1.3, this value was not processed
     if (empty($nbVisitsConverted)) {
         $nbVisitsConverted = $nbConversions;
     }
     $revenue = $dataRow->getColumn('revenue');
     $return = array('id' => $idGoal, 'nb_conversions' => (int) $nbConversions, 'nb_visits_converted' => (int) $nbVisitsConverted, 'conversion_rate' => $this->formatConversionRate($dataRow->getColumn('conversion_rate')), 'revenue' => $revenue ? $revenue : 0, 'urlSparklineConversions' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_conversions'), 'idGoal' => $idGoal)), 'urlSparklineConversionRate' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('conversion_rate'), 'idGoal' => $idGoal)), 'urlSparklineRevenue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('revenue'), 'idGoal' => $idGoal)));
     if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
         $items = $dataRow->getColumn('items');
         $aov = $dataRow->getColumn('avg_order_revenue');
         $return = array_merge($return, array('revenue_subtotal' => $dataRow->getColumn('revenue_subtotal'), 'revenue_tax' => $dataRow->getColumn('revenue_tax'), 'revenue_shipping' => $dataRow->getColumn('revenue_shipping'), 'revenue_discount' => $dataRow->getColumn('revenue_discount'), 'items' => $items ? $items : 0, 'avg_order_revenue' => $aov ? $aov : 0, 'urlSparklinePurchasedProducts' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('items'), 'idGoal' => $idGoal)), 'urlSparklineAverageOrderValue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_order_revenue'), 'idGoal' => $idGoal))));
     }
     return $return;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:20,代码来源:Controller.php


注:本文中的Piwik\API\Request::process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。