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


PHP Http::sendHttpRequest方法代码示例

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


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

示例1: testWebArchiving

 public function testWebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n";
         $message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n";
         $message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}";
         $this->markTestSkipped($message);
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertContains('Starting Piwik reports archiving...', $output);
     $this->assertContains('Archived website id = 1', $output);
     $this->assertContains('Done archiving!', $output);
     $this->compareArchivePhpOutputAgainstExpected($output);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:28,代码来源:ArchiveWebTest.php

示例2: triggerWebtreesAdminTasks

 public function triggerWebtreesAdminTasks()
 {
     $settings = new Settings();
     $this->logger = \Piwik\Container\StaticContainer::get('Psr\\Log\\LoggerInterface');
     $this->logger->info('Webtrees Admin Task triggered');
     $rooturl = $settings->getSetting('webtreesRootUrl');
     if (!$rooturl || strlen($rooturl->getValue()) === 0) {
         return;
     }
     $token = $settings->getSetting('webtreesToken');
     if (!$token || strlen($token->getValue()) === 0) {
         return;
     }
     $taskname = $settings->getSetting('webtreesTaskName');
     if (!$taskname || strlen($taskname->getValue()) === 0) {
         return;
     }
     $url = sprintf('%1$s/module.php?mod=perso_admintasks&mod_action=trigger&force=%2$s&task=%3$s', $rooturl->getValue(), $token->getValue(), $taskname->getValue());
     $this->logger->info('webtrees url : {url}', array('url' => $url));
     try {
         \Piwik\Http::sendHttpRequest($url, Webtrees::SOCKET_TIMEOUT);
     } catch (Exception $e) {
         $this->logger->warning('an error occured', array('exception' => $e));
     }
 }
开发者ID:jon48,项目名称:webtrees-tools,代码行数:25,代码来源:Tasks.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $buildNumber = $input->getArgument('buildnumber');
     $screenshotsRegex = $input->getArgument('screenshotsRegex');
     if (empty($buildNumber)) {
         throw new \InvalidArgumentException('Missing build number.');
     }
     $urlBase = sprintf('http://builds-artifacts.piwik.org/ui-tests.master/%s', $buildNumber);
     $diffviewer = Http::sendHttpRequest($urlBase . "/screenshot-diffs/diffviewer.html", $timeout = 60);
     $diffviewer = str_replace('&', '&', $diffviewer);
     $dom = new \DOMDocument();
     $dom->loadHTML($diffviewer);
     foreach ($dom->getElementsByTagName("tr") as $row) {
         $columns = $row->getElementsByTagName("td");
         $nameColumn = $columns->item(0);
         $processedColumn = $columns->item(3);
         $testPlugin = null;
         if ($nameColumn && preg_match("/\\(for ([a-zA-Z_]+) plugin\\)/", $dom->saveXml($nameColumn), $matches)) {
             $testPlugin = $matches[1];
         }
         $file = null;
         if ($processedColumn && preg_match("/href=\".*\\/(.*)\"/", $dom->saveXml($processedColumn), $matches)) {
             $file = $matches[1];
         }
         if ($file !== null && preg_match("/" . $screenshotsRegex . "/", $file)) {
             if ($testPlugin == null) {
                 $downloadTo = "tests/PHPUnit/UI/expected-ui-screenshots/{$file}";
             } else {
                 $downloadTo = "plugins/{$testPlugin}/tests/UI/expected-ui-screenshots/{$file}";
             }
             $output->write("<info>Downloading {$file} to .{$downloadTo}...</info>\n");
             Http::sendHttpRequest("{$urlBase}/processed-ui-screenshots/{$file}", $timeout = 60, $userAgent = null, PIWIK_DOCUMENT_ROOT . "/" . $downloadTo);
         }
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:35,代码来源:SyncUITestScreenshots.php

示例4: check

 /**
  * Check for a newer version
  *
  * @param bool $force Force check
  * @param int $interval Interval used for update checks
  */
 public static function check($force = false, $interval = null)
 {
     if (!self::isAutoUpdateEnabled()) {
         return;
     }
     if ($interval === null) {
         $interval = self::CHECK_INTERVAL;
     }
     $lastTimeChecked = Option::get(self::LAST_TIME_CHECKED);
     if ($force || $lastTimeChecked === false || time() - $interval > $lastTimeChecked) {
         // set the time checked first, so that parallel Piwik requests don't all trigger the http requests
         Option::set(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
         $parameters = array('piwik_version' => Version::VERSION, 'php_version' => PHP_VERSION, 'url' => Url::getCurrentUrlWithoutQueryString(), 'trigger' => Common::getRequestVar('module', '', 'string'), 'timezone' => API::getInstance()->getDefaultTimezone());
         $url = Config::getInstance()->General['api_service_url'] . '/1.0/getLatestVersion/' . '?' . http_build_query($parameters, '', '&');
         $timeout = self::SOCKET_TIMEOUT;
         if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) {
             $url = 'http://builds.piwik.org/LATEST_BETA';
         }
         try {
             $latestVersion = Http::sendHttpRequest($url, $timeout);
             if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
                 $latestVersion = '';
             }
         } catch (Exception $e) {
             // e.g., disable_functions = fsockopen; allow_url_open = Off
             $latestVersion = '';
         }
         Option::set(self::LATEST_VERSION, $latestVersion);
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:36,代码来源:UpdateCheck.php

示例5: getPage

 /**
  * Web service proxy that retrieves the content at the specified URL
  *
  * @param string $url
  * @return string
  */
 private function getPage($url)
 {
     try {
         return str_replace('&nbsp;', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']));
     } catch (Exception $e) {
         return '';
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:14,代码来源:RankChecker.php

示例6: updateSocials

 /**
  * Update the social definitions
  *
  * @see https://github.com/piwik/searchengine-and-social-list
  */
 public function updateSocials()
 {
     $url = 'https://raw.githubusercontent.com/piwik/searchengine-and-social-list/master/Socials.yml';
     $list = Http::sendHttpRequest($url, 30);
     $socials = Social::getInstance()->loadYmlData($list);
     if (count($socials) < 50) {
         return;
     }
     Option::set(Social::OPTION_STORAGE_NAME, base64_encode(serialize($socials)));
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:15,代码来源:Tasks.php

示例7: getLatestAvailableVersionNumber

 /**
  * Get the latest available version number for the currently active release channel. Eg '2.15.0-b4' or '2.15.0'.
  * Should return a semantic version number in format MAJOR.MINOR.PATCH (http://semver.org/).
  * Returns an empty string in case one cannot connect to the remote server.
  * @return string
  */
 private static function getLatestAvailableVersionNumber()
 {
     $channel = StaticContainer::get('\\Piwik\\Plugin\\ReleaseChannels')->getActiveReleaseChannel();
     $url = $channel->getUrlToCheckForLatestAvailableVersion();
     try {
         $latestVersion = Http::sendHttpRequest($url, self::SOCKET_TIMEOUT);
     } catch (\Exception $e) {
         // e.g., disable_functions = fsockopen; allow_url_open = Off
         $latestVersion = '';
     }
     return $latestVersion;
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:18,代码来源:UpdateCheck.php

示例8: isPageSpeedEnabled

 private function isPageSpeedEnabled()
 {
     $url = Url::getCurrentUrlWithoutQueryString() . '?module=Installation&action=getEmptyPageForSystemCheck';
     try {
         $page = Http::sendHttpRequest($url, $timeout = 1, $userAgent = null, $destinationPath = null, $followDepth = 0, $acceptLanguage = false, $byteRange = false, $getExtendedInfo = true);
     } catch (\Exception $e) {
         $this->logger->info('Unable to test if mod_pagespeed is enabled: the request to {url} failed', array('url' => $url));
         // If the test failed, we assume Page speed is not enabled
         return false;
     }
     $headers = $page['headers'];
     return isset($headers['X-Mod-Pagespeed']) || isset($headers['X-Page-Speed']);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:13,代码来源:PageSpeedCheck.php

示例9: getAllTlds

 private function getAllTlds()
 {
     /** @var array $response */
     $response = \Piwik\Http::sendHttpRequest("http://data.iana.org/TLD/tlds-alpha-by-domain.txt", 30, null, null, null, null, null, true);
     $this->assertEquals("200", $response['status']);
     $tlds = explode("\n", $response['data']);
     foreach ($tlds as $key => $tld) {
         if (strpos($tld, '#') !== false || $tld == "") {
             unset($tlds[$key]);
         }
     }
     return $tlds;
 }
开发者ID:andrzejewsky,项目名称:piwik,代码行数:13,代码来源:EmailValidatorTest.php

示例10: fetchPageRank

 public function fetchPageRank($domain)
 {
     $chwrite = $this->checkHash($this->hashURL($domain));
     $url = "http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=" . $chwrite . "&features=Rank&q=info:" . $domain . "&num=100&filter=0";
     try {
         $response = Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']);
         preg_match('#Rank_[0-9]:[0-9]:([0-9]+){1,}#si', $response, $p);
         return isset($p[1]) ? $p[1] : null;
     } catch (\Exception $e) {
         $this->logger->warning('Error while getting Google PageRank for SEO stats: {message}', array('message' => $e->getMessage()));
         return null;
     }
 }
开发者ID:drabberhorizon,项目名称:ActiveNative,代码行数:13,代码来源:Google.php

示例11: getMetrics

 public function getMetrics($domain)
 {
     try {
         $response = Http::sendHttpRequest(self::URL . urlencode($domain), $timeout = 10, @$_SERVER['HTTP_USER_AGENT']);
         $xml = @simplexml_load_string($response);
         $value = $xml ? (string) $xml->SD->POPULARITY['TEXT'] : null;
     } catch (\Exception $e) {
         $this->logger->warning('Error while getting Alexa SEO stats: {message}', array('message' => $e->getMessage()));
         $value = null;
     }
     $logo = \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://alexa.com');
     $link = self::LINK . urlencode($domain);
     return array(new Metric('alexa', 'SEO_AlexaRank', $value, $logo, $link));
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:14,代码来源:Alexa.php

示例12: fetchIndexedPagesCount

 public function fetchIndexedPagesCount($domain)
 {
     $url = self::SEARCH_URL . urlencode($domain);
     try {
         $response = str_replace('&nbsp;', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']));
         if (preg_match('#([0-9,\\.]+) results#i', $response, $p)) {
             return NumberFormatter::getInstance()->formatNumber((int) str_replace(array(',', '.'), '', $p[1]));
         } else {
             return 0;
         }
     } catch (\Exception $e) {
         $this->logger->warning('Error while getting Google search SEO stats: {message}', array('message' => $e->getMessage()));
         return null;
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:15,代码来源:Google.php

示例13: getAllTlds

 private function getAllTlds()
 {
     /** @var array $response */
     $response = \Piwik\Http::sendHttpRequest("http://data.iana.org/TLD/tlds-alpha-by-domain.txt", 30, null, null, null, null, null, true);
     $this->assertEquals("200", $response['status']);
     $tlds = explode("\n", $response['data']);
     foreach ($tlds as $key => $tld) {
         if (strpos($tld, '#') !== false || $tld == "") {
             unset($tlds[$key]);
         }
     }
     $minimumTlds = 1200;
     $this->assertGreaterThan($minimumTlds, count($tlds), "expected to download at least {$minimumTlds} domain names");
     return $tlds;
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:15,代码来源:EmailValidatorTest.php

示例14: getBacklinkStats

 /**
  * Returns backlink statistics including the count of backlinks and count of
  * referrer domains (domains with backlinks).
  *
  * This method issues an HTTP request and waits for it to return.
  *
  * @param string $siteDomain The domain of the website to get stats for.
  * @param int $timeout The number of seconds to wait before aborting
  *                     the HTTP request.
  * @return array An array containing the backlink count and referrer
  *               domain count:
  *               array(
  *                   'backlink_count' => X,
  *                   'referrer_domains_count' => Y
  *               )
  *               If either stat is false, either the API returned an
  *               error, or the IP was blocked for this request.
  */
 public function getBacklinkStats($siteDomain, $timeout = 300)
 {
     $apiUrl = $this->getApiUrl($method = 'GetBacklinkStats', $args = array('items' => '1', 'item0' => $siteDomain));
     $apiResponse = Http::sendHttpRequest($apiUrl, $timeout);
     $result = array('backlink_count' => false, 'referrer_domains_count' => false);
     $apiResponse = Common::json_decode($apiResponse, $assoc = true);
     if (!empty($apiResponse) && !empty($apiResponse['Data'])) {
         $siteSeoStats = reset($apiResponse['Data']);
         if (isset($siteSeoStats['ExtBackLinks']) && $siteSeoStats['ExtBackLinks'] !== -1) {
             $result['backlink_count'] = $siteSeoStats['ExtBackLinks'];
         }
         if (isset($siteSeoStats['RefDomains']) && $siteSeoStats['RefDomains'] !== -1) {
             $result['referrer_domains_count'] = $siteSeoStats['RefDomains'];
         }
     }
     return $result;
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:35,代码来源:MajesticClient.php

示例15: getMetrics

 public function getMetrics($domain)
 {
     $url = self::URL . urlencode($domain);
     try {
         $response = str_replace('&nbsp;', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']));
         if (preg_match('#([0-9,\\.]+) results#i', $response, $p)) {
             $pageCount = NumberFormatter::getInstance()->formatNumber((int) str_replace(array(',', '.'), '', $p[1]));
         } else {
             $pageCount = 0;
         }
     } catch (\Exception $e) {
         $this->logger->warning('Error while getting Bing SEO stats: {message}', array('message' => $e->getMessage()));
         $pageCount = null;
     }
     $logo = SearchEngine::getInstance()->getLogoFromUrl('http://bing.com');
     return array(new Metric('bing-index', 'SEO_Bing_IndexedPages', $pageCount, $logo, null, null, 'General_Pages'));
 }
开发者ID:piwik,项目名称:piwik,代码行数:17,代码来源:Bing.php


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