getAuthToken() ?: 'anonymous'; $format = Common::getRequestVar('format', false); $serialize = Common::getRequestVar('serialize', false); // when calling the API through http, we limit the number of returned results if (!isset($_GET['filter_limit'])) { if (isset($_POST['filter_limit'])) { $_GET['filter_limit'] = $_POST['filter_limit']; } else { $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit']; } } $request = new Request([ 'token_auth' => $tokenAuth, ]); $response = $request->process(); if (is_array($response)) { if ( $format == 'original' && $serialize != 1 ) { Original::sendPlainTextHeader(); } $response = var_export($response, true); } return $response; } public function listAllMethods() { Piwik::checkUserHasSomeViewAccess(); $ApiDocumentation = new DocumentationGenerator(); $prefixUrls = Common::getRequestVar('prefixUrl', 'https://demo.matomo.cloud/', 'string'); $parsedUrl = parse_url($prefixUrls); if (empty($parsedUrl['host']) || !UrlHelper::isLookLikeUrl($prefixUrls) || strpos($prefixUrls, 'http') !== 0 || !Url::isValidHost($parsedUrl['host'])) { $prefixUrls = ''; } else { // We put together the url based on the parsed parameters manually to ensure it might not contain unexpected locations // unescaped slashes in username or password part for example have unexpected results in browsers unset($parsedUrl['query'], $parsedUrl['fragment']); $prefixUrls = UrlHelper::getParseUrlReverse($parsedUrl); } return $ApiDocumentation->getApiDocumentationAsStringForDeveloperReference($outputExampleUrls = true, $prefixUrls); } public function listAllAPI() { $view = new View("@API/listAllAPI"); $this->setGeneralVariablesView($view); $ApiDocumentation = new DocumentationGenerator(); $view->countLoadedAPI = Proxy::getInstance()->getCountRegisteredClasses(); $view->list_api_methods_with_links = str_replace('href=\'#', 'href=\'#/', $ApiDocumentation->getApiDocumentationAsString()); return $view->render(); } public function listSegments() { $segments = API::getInstance()->getSegmentsMetadata($this->idSite); $tableDimensions = $tableMetrics = ''; $customVariables = 0; $lastCategory = array(); foreach ($segments as $segment) { $onlyDisplay = array('customVariableName1', 'customVariableName2', 'customVariableValue1', 'customVariableValue2', 'customVariablePageName1', 'customVariablePageValue1'); $customVariableWillBeDisplayed = in_array($segment['segment'], $onlyDisplay); // Don't display more than 4 custom variables name/value rows if ( $segment['category'] == 'Custom Variables' && !$customVariableWillBeDisplayed ) { continue; } $thisCategory = $segment['category']; $output = ''; if ( empty($lastCategory[$segment['type']]) || $lastCategory[$segment['type']] != $thisCategory ) { $output .= '
' . $segment['acceptedValues'] . ''
: '';
$restrictedToAdmin = isset($segment['permission']) ? 'customVariableName1==Type;customVariableValue1==Customer
customVariablePageName1==ArticleLanguage;customVariablePageValue1==FR