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


PHP API\Request类代码示例

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


在下文中一共展示了Request类的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: 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

示例5: 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

示例6: 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:ahdinosaur,项目名称:analytics.dinosaur.is,代码行数:10,代码来源:RequestTest.php

示例7: 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

示例8: 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:CaptainSharf,项目名称:SSAD_Project,代码行数:15,代码来源:Controller.php

示例9: 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

示例10: createTrackToOwnPiwikSetting

 private function createTrackToOwnPiwikSetting()
 {
     return $this->makeSetting('ownPiwikSiteId', $default = 0, FieldConfig::TYPE_INT, function (FieldConfig $field) {
         $field->title = 'Site Id';
         // ideally we would use a SELECT control and let user choose an existing site but this would make performance slow
         // since we'd always have to get all site ids in each request
         $field->uiControl = FieldConfig::UI_CONTROL_TEXT;
         $field->introduction = 'Send anonymize usage data to this Piwik';
         $field->description = 'If specified, anonymized usage data will be sent to the specified site in this Piwik.';
         $field->validate = function ($idSite) {
             if (empty($idSite)) {
                 return;
             }
             if (!is_numeric($idSite)) {
                 throw new Exception("Site Id '{$idSite}' should be a number");
             }
             $idSite = (int) $idSite;
             try {
                 $siteExists = Request::processRequest('SitesManager.getSiteFromId', array('idSite' => $idSite));
             } catch (Exception $e) {
                 $siteExists = false;
             }
             if (!$siteExists) {
                 throw new Exception("The specified idSite '{$idSite}' does not exist");
             }
         };
     });
 }
开发者ID:piwik,项目名称:plugin-AnonymousPiwikUsageMeasurement,代码行数:28,代码来源:SystemSettings.php

示例11: getRequestArray

 /**
  * @return array  URL to call the API, eg. "method=Referrers.getKeywords&period=day&date=yesterday"...
  */
 public function getRequestArray()
 {
     // we prepare the array to give to the API Request
     // we setup the method and format variable
     // - we request the method to call to get this specific DataTable
     // - the format = original specifies that we want to get the original DataTable structure itself, not rendered
     $requestArray = array('method' => $this->requestConfig->apiMethodToRequestDataTable, 'format' => 'original');
     $toSetEventually = array('filter_limit', 'keep_summary_row', 'filter_sort_column', 'filter_sort_order', 'filter_excludelowpop', 'filter_excludelowpop_value', 'filter_column', 'filter_pattern', 'flat', 'expanded', 'pivotBy', 'pivotByColumn', 'pivotByColumnLimit');
     foreach ($toSetEventually as $varToSet) {
         $value = $this->getDefaultOrCurrent($varToSet);
         if (false !== $value) {
             $requestArray[$varToSet] = $value;
         }
     }
     $segment = ApiRequest::getRawSegmentFromRequest();
     if (!empty($segment)) {
         $requestArray['segment'] = $segment;
     }
     if (ApiRequest::shouldLoadExpanded()) {
         $requestArray['expanded'] = 1;
     }
     $requestArray = array_merge($requestArray, $this->requestConfig->request_parameters_to_modify);
     if (!empty($requestArray['filter_limit']) && $requestArray['filter_limit'] === 0) {
         unset($requestArray['filter_limit']);
     }
     if ($this->requestConfig->disable_generic_filters) {
         $requestArray['disable_generic_filters'] = '1';
     }
     if ($this->requestConfig->disable_queued_filters) {
         $requestArray['disable_queued_filters'] = 1;
     }
     return $requestArray;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:36,代码来源:Request.php

示例12: getContentNames

 protected function getContentNames($websiteId = null, $date = null)
 {
     if (!is_null($websiteId)) {
         return \Piwik\API\Request::processRequest('Contents.getContentNames', array('idSite' => $websiteId, 'period' => 'year', 'date' => $date));
     }
     return Db::fetchAssoc("select `idaction`, `name` from `{$this->tablePrefix}log_action` where `type` = ?", array(\Piwik\Tracker\Action::TYPE_CONTENT_NAME));
 }
开发者ID:Ratus,项目名称:VPSCashPiwikBannerPlugin,代码行数:7,代码来源:Update.php

示例13: elementLiveLoadBars

 /**
  * This widget shows horizontal bars with cpu load, memory use, network traffic and disk use
  **/
 function elementLiveLoadBars()
 {
     $result = Request::processRequest('SimpleSysMon.getLiveSysLoadData');
     $view = new View('@SimpleSysMon/widgetLiveSysLoadBars.twig');
     $this->setBasicVariablesView($view);
     $view->sysLoad = array('avgload' => array('used' => round($result['AvgLoad'], 0), 'free' => round(100.0 - $result['AvgLoad'], 0)), 'memory' => array('procUsed' => round($result['UsedMemProc'], 0), 'procCached' => round($result['CachedMemProc'], 0), 'procFree' => round(100.0 - $result['UsedMemProc'], 0), 'valUsed' => round($result['UsedMemVal'], 0), 'valCached' => round($result['CachedMemVal'], 0), 'valFree' => round($result['FreeMemProc'], 0)), 'net' => array('procUpload' => round($result['UpNetProc'], 0), 'procDownload' => round($result['DownNetProc'], 0), 'procFree' => round(100.0 - $result['DownNetProc'], 0), 'valUpload' => round($result['UpNetVal'], 0), 'valDownload' => round($result['DownNetVal'], 0)), 'disk' => array('procUsed' => round($result['UsedDiskProc'], 0), 'procFree' => round($result['FreeDiskProc'], 0), 'valUsed' => round($result['UsedDiskVal'], 0), 'valFree' => round($result['FreeDiskVal'], 0)));
     return $view->render();
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:11,代码来源:Controller.php

示例14: makeSureTestRunsInContextOfAnonymousUser

 private function makeSureTestRunsInContextOfAnonymousUser()
 {
     Piwik::postEvent('Request.initAuthenticationObject');
     $access = Access::getInstance();
     $this->hasSuperUserAccess = $access->hasSuperUserAccess();
     $access->setSuperUserAccess(false);
     $access->reloadAccess(StaticContainer::get('Piwik\\Auth'));
     Request::reloadAuthUsingTokenAuth(array('token_auth' => 'anonymous'));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:APITest.php

示例15: 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


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