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


PHP Piwik\Http类代码示例

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


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

 public function get()
 {
     try {
         $content = Http::fetchRemoteFile($this->url);
         $rss = simplexml_load_string($content);
     } catch (\Exception $e) {
         echo "Error while importing feed: {$e->getMessage()}\n";
         exit;
     }
     $output = '<div style="padding:10px 15px;"><ul class="rss">';
     $i = 0;
     $items = array();
     if (!empty($rss->channel->item)) {
         $items = $rss->channel->item;
     }
     foreach ($items as $post) {
         $title = $post->title;
         $date = @strftime("%B %e, %Y", strtotime($post->pubDate));
         $link = $post->link;
         $output .= '<li><a class="rss-title" title="" target="_blank" href="?module=Proxy&action=redirect&url=' . $link . '">' . $title . '</a>' . '<span class="rss-date">' . $date . '</span>';
         if ($this->showDescription) {
             $output .= '<div class="rss-description">' . $post->description . '</div>';
         }
         if ($this->showContent) {
             $output .= '<div class="rss-content">' . $post->content . '</div>';
         }
         $output .= '</li>';
         if (++$i == $this->count) {
             break;
         }
     }
     $output .= '</ul></div>';
     return $output;
 }
开发者ID:piwik,项目名称:piwik,代码行数:34,代码来源:RssRenderer.php

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

示例7: sendSMS

 public function sendSMS($apiKey, $smsText, $phoneNumber, $from)
 {
     $account = explode(" ", $apiKey);
     $parameters = array('user' => $account[0], 'pass' => $account[1], 'msg' => $smsText);
     $url = self::API_URL . '?' . http_build_query($parameters, '', '&');
     $timeout = self::SOCKET_TIMEOUT;
     $result = Http::sendHttpRequestBy(Http::getTransportMethod(), $url, $timeout, $getExtendedInfo = true);
 }
开发者ID:apapillon,项目名称:piwik-freemobilesmsprovider-plugin,代码行数:8,代码来源:FreeMobile.php

示例8: trackVisits

 private function trackVisits()
 {
     if (!$this->trackInvalidRequests) {
         return;
     }
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
     API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
     // Trigger empty request
     $trackerUrl = self::getTrackerUrl();
     $response = Http::fetchRemoteFile($trackerUrl);
     self::assertTrue(strpos($response, 'is a free open source web') !== false, 'Piwik empty request response not correct: ' . $response);
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true);
     // test GoogleBot UA visitor
     $t->setUserAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
     self::checkResponse($t->doTrackPageView('bot visit, please do not record'));
     // Test IP Exclusion works with or without IP exclusion
     foreach (array(false, true) as $enable) {
         $excludedIp = '154.1.12.34';
         API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
         // Enable IP Anonymization
         $t->DEBUG_APPEND_URL = '&forceIpAnonymization=' . (int) $enable;
         // test with excluded User Agent
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) (excludeduseragentstring)');
         $t->setIp('211.1.2.3');
         self::checkResponse($t->doTrackPageView('visit from excluded User Agent'));
         $t->setUserAgent('Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0 Google (+https://developers.google.com/+/web/snippet/)');
         self::checkResponse($t->doTrackPageView('visit from excluded User Agent'));
         // test w/ global excluded User Agent
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) (globalexcludeduseragent)');
         $t->setIp('211.1.2.3');
         self::checkResponse($t->doTrackPageView('visit from global excluded User Agent'));
         // test with excluded IP
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
         // restore normal user agent
         $t->setIp($excludedIp);
         self::checkResponse($t->doTrackPageView('visit from IP excluded'));
         // test with global list of excluded IPs
         $excludedIpBis = '145.5.3.4';
         API::getInstance()->setGlobalExcludedIps($excludedIpBis);
         $t->setIp($excludedIpBis);
         self::checkResponse($t->doTrackPageView('visit from IP globally excluded'));
     }
     try {
         @$t->setAttributionInfo(array());
         self::fail();
     } catch (Exception $e) {
     }
     try {
         $t->setAttributionInfo(json_encode('test'));
         self::fail();
     } catch (Exception $e) {
     }
     $t->setAttributionInfo(json_encode(array()));
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:56,代码来源:InvalidVisits.php

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

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

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

示例12: testHEADOperation

 /**
  * @group Core
  * 
  * @dataProvider getMethodsToTest
  */
 public function testHEADOperation($method)
 {
     if ($method == 'fopen') {
         return;
         // not supported w/ this method
     }
     $result = Http::sendHttpRequestBy($method, 'http://builds.piwik.org/latest.zip', 30, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSslCertificate = false, $byteRange = false, $getExtendedInfo = true, $httpMethod = 'HEAD');
     $this->assertEquals('', $result['data']);
     $this->assertEquals(200, $result['status']);
     $this->assertTrue(isset($result['headers']['Content-Length']), "Content-Length header not set!");
     $this->assertTrue(is_numeric($result['headers']['Content-Length']), "Content-Length header not numeric!");
     $this->assertEquals('application/zip', $result['headers']['Content-Type']);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:18,代码来源:HttpTest.php

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

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

示例15: execute

 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckOpenURL');
     $httpMethod = Http::getTransportMethod();
     if ($httpMethod) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, $httpMethod));
     }
     $canAutoUpdate = Filechecks::canAutoUpdate();
     $comment = $this->translator->translate('Installation_SystemCheckOpenURLHelp');
     if (!$canAutoUpdate) {
         $comment .= '<br/>' . $this->translator->translate('Installation_SystemCheckAutoUpdateHelp');
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:14,代码来源:HttpClientCheck.php


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