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


PHP HTTP::get方法代码示例

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


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

示例1: export

	function export($out) {
		$data = $this->data;
		
		$tmp = tempnam(sys_get_temp_dir(), 'phpinstaller-') . '.zip';
		
		HTTP::get("https://github.com/{$data['user']}/{$data['project']}/zipball/{$data['branch']}", $tmp);
		Zip::import($tmp, $out, 1);		
	}
开发者ID:redema,项目名称:silverstripe-installer,代码行数:8,代码来源:sources.php

示例2: testEmailImages

 /**
  * Make sure all the images we're using exist
  */
 public function testEmailImages()
 {
     $this->setVignetteEnvToProd();
     $this->disableMemCache();
     foreach (Email\ImageHelper::getIconInfo() as $iconInfo) {
         $url = $iconInfo['url'];
         $name = $iconInfo['name'];
         $response = HTTP::get($url);
         $this->assertTrue($response !== false, "{$name} should return HTTP 200 -- {$url}");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:EmailIntegrationTest.php

示例3: __construct

 public function __construct()
 {
     $pgHTTP = new HTTP();
     $text = $pgHTTP->get('http://meta.wikimedia.org/w/index.php?title=IRC/Quotes&action=raw&ctype=text/css', false);
     $text = explode('<pre><nowiki>', $text);
     $text = explode('</nowiki></pre>', $text[1]);
     $text = explode('%%', $text[0]);
     $text = substr($text[0], 2);
     $text = htmlspecialchars($text);
     $text = trim($text);
     $text = preg_replace('/\\n/', '<br />', $text);
     $this->quotes = explode("%<br />", $text);
 }
开发者ID:Krinkle,项目名称:xtools,代码行数:13,代码来源:base.php

示例4: __construct

 public function __construct(WebRequest $request)
 {
     parent::__construct($request);
     global $IP, $wgUser;
     $ac = new AssetsConfig();
     $assets = $ac->resolve($this->mOid, true, !isset($this->mParams['minify']) || $this->mParams['minify'] == true, $this->mParams);
     $this->mContentType = $ac->getGroupType($this->mOid);
     foreach ($assets as $asset) {
         // reference to a file to be fetched by the browser from external server (BugId:9522)
         if (substr($asset, 0, 10) == '#external_') {
             // do nothing
         } else {
             if (Http::isValidURI($asset)) {
                 $params = array();
                 $url = parse_url($asset);
                 if (isset($url['query'])) {
                     parse_str($url['query'], $params);
                 }
                 // Start checking the url to see if it is something we care about (BugId:30188)
                 if (isset($params['action']) && $params['action'] == 'raw' && isset($params['gen']) && $params['gen'] == 'js') {
                     //$this->mContent .= RequestContext::getMain()->getSkin()->generateUserJs(); // FIXME
                 } else {
                     if (isset($params['action']) && $params['action'] == 'raw' && isset($params['gen']) && $params['gen'] == 'css') {
                         //$this->mContent .= RequestContext::getMain()->getSkin()->generateUserStylesheet(); // FIXME
                     } else {
                         //Debug added on May 4, 2012 to inquire external requests spikes
                         $start = microtime(true);
                         $this->mContent .= HTTP::get($asset);
                         $totalTime = microtime(true) - $start;
                         if ($totalTime >= 1) {
                             Wikia::log(__METHOD__, false, "oid: {$this->mOid}, totalTime: {$totalTime}, asset: {$asset}, referrer: {$_SERVER['HTTP_REFERER']}, entrypoint: {$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}", true);
                         }
                     }
                 }
             } else {
                 $this->mContent .= file_get_contents($IP . '/' . $asset);
             }
         }
         if ($this->mContentType == AssetsManager::TYPE_JS) {
             // add semicolon to separate concatenated files (BugId:20272)
             // but only for JS (BugId:20824)
             $this->mContent .= ";\n";
         }
     }
     // For RTE only
     // TODO: add "filters" definitions to config.php
     if ($this->mOid == 'rte' || $this->mOid == 'eplrte' || $this->mOid == 'mini_editor_rte_js') {
         $this->mContent = preg_replace('#^.*@Packager\\.RemoveLine.*$#m', '', $this->mContent);
         $this->mContent = str_replace("", '', $this->mContent);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:51,代码来源:AssetsManagerGroupBuilder.class.php

示例5: getNamespaceNames

 static function getNamespaceNames($lang, $wiki)
 {
     $http = new HTTP();
     $namespaces = $http->get("http://{$lang}.{$wiki}.org/w/api.php?action=query&meta=siteinfo&siprop=namespaces&format=php");
     $namespaces = unserialize($namespaces);
     $namespaces = $namespaces['query']['namespaces'];
     unset($namespaces[-2]);
     unset($namespaces[-1]);
     $namespaces[0]['*'] = "Mainspace";
     $namespacenames = array();
     foreach ($namespaces as $value => $ns) {
         $namespacenames[$value] = $ns['*'];
     }
     #print_r($namespacenames);die;
     return $namespacenames;
 }
开发者ID:JackPotte,项目名称:xtools,代码行数:16,代码来源:base.php

示例6: extractVideoId

 protected function extractVideoId($url)
 {
     global $wgMemc;
     $cacheKey = wfMemcKey('video', 'viddler', sha1($url));
     $cachedEmbedId = $wgMemc->get($cacheKey);
     if ($cachedEmbedId !== false) {
         return $cachedEmbedId;
     }
     $apiUrl = 'http://lab.viddler.com/services/oembed/?format=json&url=' . urlencode($url);
     $apiResult = HTTP::get($apiUrl);
     if ($apiResult === false) {
         return null;
     }
     $apiResult = FormatJson::decode($apiResult, true);
     // Extract the player source from the HTML
     if (!preg_match(self::idRegex, $apiResult['html'], $matches)) {
         return null;
     }
     $embedId = $matches['id'];
     $wgMemc->set($cacheKey, $embedId, 60 * 60 * 24);
     return $embedId;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:ViddlerVideo.php

示例7: testAddFilePartial

 /**
  * @depends testGetFile
  */
 public function testAddFilePartial($getFileData)
 {
     $oldFilename = "work/old";
     $fileContents = $getFileData['response']->getBody();
     file_put_contents($oldFilename, $fileContents);
     $newFilename = "work/new";
     $patchFilename = "work/patch";
     $algorithms = array("bsdiff" => "bsdiff " . escapeshellarg($oldFilename) . " " . escapeshellarg($newFilename) . " " . escapeshellarg($patchFilename), "xdelta" => "xdelta3 -f -e -9 -S djw -s " . escapeshellarg($oldFilename) . " " . escapeshellarg($newFilename) . " " . escapeshellarg($patchFilename), "vcdiff" => "vcdiff encode " . "-dictionary " . escapeshellarg($oldFilename) . " " . " -target " . escapeshellarg($newFilename) . " " . " -delta " . escapeshellarg($patchFilename));
     foreach ($algorithms as $algo => $cmd) {
         clearstatcache();
         // Create random contents
         file_put_contents($newFilename, uniqid(self::getRandomUnicodeString(), true));
         $newHash = md5_file($newFilename);
         // Get upload authorization
         $fileParams = array("md5" => $newHash, "filename" => "test_" . $fileContents, "filesize" => filesize($newFilename), "mtime" => filemtime($newFilename) * 1000, "contentType" => "text/plain", "charset" => "utf-8");
         $response = API::userPost(self::$config['userID'], "items/{$getFileData['key']}/file?key=" . self::$config['apiKey'], $this->implodeParams($fileParams), array("Content-Type: application/x-www-form-urlencoded", "If-Match: " . md5_file($oldFilename)));
         $this->assert200($response);
         $json = json_decode($response->getBody());
         $this->assertNotNull($json);
         exec($cmd);
         $patch = file_get_contents($patchFilename);
         $this->assertNotEquals("", $patch);
         self::$toDelete[] = "{$newHash}/test_{$newHash}";
         // Upload patch file
         $response = API::userPatch(self::$config['userID'], "items/{$getFileData['key']}/file?key=" . self::$config['apiKey'] . "&algorithm={$algo}&upload=" . $json->uploadKey, $patch, array("If-Match: " . md5_file($oldFilename)));
         $this->assert204($response);
         unlink($patchFilename);
         rename($newFilename, $oldFilename);
         // Verify attachment item metadata
         $response = API::userGet(self::$config['userID'], "items/{$getFileData['key']}?key=" . self::$config['apiKey'] . "&content=json");
         $xml = API::getXMLFromResponse($response);
         $json = json_decode(array_shift($xml->xpath('/atom:entry/atom:content')));
         $this->assertEquals($fileParams['md5'], $json->md5);
         $this->assertEquals($fileParams['mtime'], $json->mtime);
         $this->assertEquals($fileParams['contentType'], $json->contentType);
         $this->assertEquals($fileParams['charset'], $json->charset);
         // Verify file on S3
         $response = API::userGet(self::$config['userID'], "items/{$getFileData['key']}/file?key=" . self::$config['apiKey']);
         $this->assert302($response);
         $location = $response->getHeader("Location");
         $response = HTTP::get($location);
         $this->assert200($response);
         $this->assertEquals($fileParams['md5'], md5($response->getBody()));
         $t = $fileParams['contentType'];
         $this->assertEquals($t . ($t && $fileParams['charset'] ? "; charset={$fileParams['charset']}" : ""), $response->getHeader("Content-Type"));
     }
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:50,代码来源:FileTest.php

示例8: get

 public static function get($url, $headers = array(), $auth = false)
 {
     $url = self::$config['apiURLPrefix'] . $url;
     if (self::$apiVersion) {
         $headers[] = "Zotero-API-Version: " . self::$apiVersion;
     }
     if (!$auth && self::$apiKey) {
         $headers[] = "Authorization: Bearer " . self::$apiKey;
     }
     $response = HTTP::get($url, $headers, $auth);
     if (self::$config['verbose'] >= 2) {
         echo "\n\n" . $response->getBody() . "\n";
     }
     return $response;
 }
开发者ID:selenus,项目名称:dataserver,代码行数:15,代码来源:api3.inc.php

示例9: runHTTPFailureChecks

 function runHTTPFailureChecks()
 {
     // Each of the following requests should result in a failure.
     $timeout = 1;
     $start_time = time();
     $r = HTTP::get("http://www.example.com:1/", $timeout);
     $end_time = time();
     $this->assertLessThan($timeout + 2, $end_time - $start_time, "Request took less than {$timeout}s via " . Http::$httpEngine);
     $this->assertEquals($r, false, "false -- what we get on error from Http::get()");
     $r = HTTP::get("http://www.example.com/this-file-does-not-exist", $timeout);
     $this->assertFalse($r, "False on 404s");
     $r = HttpRequest::factory("http://www.example.com/this-file-does-not-exist");
     $er = $r->execute();
     if (is_a($r, 'PhpHttpRequest') && version_compare('5.2.10', phpversion(), '>')) {
         $this->assertRegexp("/HTTP request failed/", $er->getWikiText());
     } else {
         $this->assertRegexp("/404 Not Found/", $er->getWikiText());
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:19,代码来源:HttpTest.php

示例10: die

require_once '../commandLine.inc';
if (isset($options['help'])) {
    die("Update field `city_description` in table `city_list` base on media wiki msg ");
}
function deleteScript($document)
{
    $search = array('@<script[^>]*?>.*?</script>@si');
    $text = preg_replace($search, '', $document);
    return trim(strip_tags($text));
}
$sql = 'SELECT cv_id, city_url, city_description FROM `city_list`';
$db = WikiFactory::db(DB_MASTER);
$res = $db->query($sql);
$countAll = $countNoEmpty = 0;
$sql = '';
$countNoEmpty = 0;
while ($row = $db->fetchRow($res)) {
    $countAll++;
    $url = $row['city_url'] . "index.php?title=MediaWiki:Description&action=render";
    $out = HTTP::get($url);
    $out = deleteScript($out);
    if ($out != $row['city_description']) {
        echo $row['city_id'] . ":" . $row[' city_sitename'] . ":" . $countNoEmpty . "\n";
        $sql = " UPDATE city_list SET city_description =" . $db->addQuotes($out) . " where city_id=" . $row['city_id'] . ";\n";
        $db->query($sql);
        $countNoEmpty++;
    } else {
        echo "is up to date\n";
    }
}
echo "Found {$countAll} rows, {$countNoEmpty} with the wiki description updated.\n";
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:update_city_description.php

示例11: testConfigure

 public function testConfigure()
 {
     HTTP::configure(array('base' => 'http://httpbin.org', 'headers' => array('Doing' => 'tests')));
     $res = HTTP::get('/get')->send();
     $this->assertFalse($res->error());
     $this->assertEquals(200, $res->status());
     $this->assertInstanceOf('stdClass', $res->body());
 }
开发者ID:thomseddon,项目名称:http,代码行数:8,代码来源:HTTPTest.php

示例12: get

 public static function get($url, $headers = array(), $auth = false)
 {
     self::loadConfig();
     $url = self::$config['apiURLPrefix'] . $url;
     $response = HTTP::get($url, $headers, $auth);
     if (self::$config['verbose']) {
         echo "\n\n" . $response->getBody() . "\n";
     }
     return $response;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:10,代码来源:api.inc.php

示例13: wfGetDevelopersJSON

function wfGetDevelopersJSON($language, $query, $callback)
{
    $data = false;
    // differ by "language": rfc, php, js, css, ...
    switch ($language) {
        // Request For Comments
        case 'rfc':
            $rfcId = intval($query);
            if (empty($rfcId)) {
                continue;
            }
            // fetch RFC file
            $url = "http://www.faqs.org/rfcs/rfc{$rfcId}.html";
            $content = HTTP::get($url);
            // remove HTML <head> section
            $content = substr($content, strpos($content, '<HR SIZE=2 NOSHADE>'));
            //echo '<pre>'.htmlspecialchars($content).'</pre>';
            // get title and short summary
            if (preg_match('/\\- (.+)<\\/h1>/m', $content, $matches)) {
                $title = $matches[1];
                $introIdx = intval(stripos($content, 'introduction') + 12);
                $abstractIdx = intval(stripos($content, 'abstract') + 8);
                // use whatever is first
                $idx = min($introIdx, $abstractIdx) > 100 ? min($introIdx, $abstractIdx) : max($introIdx, $abstractIdx);
                $summary = trim(strip_tags(substr($content, $idx, 1024)));
            } else {
                // RFC not found - return empty title
                $title = "";
            }
            $data = array('type' => 'rfc', 'id' => $rfcId, 'title' => $title, 'summary' => !empty($summary) ? $summary : '', 'href' => "http://www.rfc-archive.org/getrfc.php?rfc={$rfcId}");
            break;
            // PHP
        // PHP
        case 'php':
            $function = preg_replace('/[^A-Za-z0-9_]/', '', $query);
            $href = 'http://us.php.net/' . $function;
            $content = HTTP::get($href);
            //echo '<pre>'.htmlspecialchars($content).'</pre>';
            // grab info from manual page
            $syntax = wfLimitText('<div class="methodsynopsis dc-description">', '<p class="para rdfs-comment">', $content);
            if (!empty($syntax)) {
                $syntax = trim(strip_tags($syntax));
                $syntax = preg_replace('/(\\s+)/', ' ', $syntax);
            }
            $description = wfLimitText('rdfs-comment">', '<div', $content);
            if (!empty($description)) {
                $description = trim(strip_tags($description), "\n. ");
                $description = preg_replace('/(\\s+)/', ' ', $description);
            }
            $params = wfLimitText('<p class="para">', '<div', $content);
            if (!empty($params)) {
                $params = trim(strip_tags($params, '<dl><dd><dt>'));
                $params = preg_replace('/(\\s+)/', ' ', $params);
            }
            $returns = wfLimitText('<h3 class="title">Return Values</h3>', '<div', $content);
            if (!empty($returns)) {
                $returns = trim(strip_tags($returns, '<p>'));
                $returns = preg_replace('/(\\s+)/', ' ', $returns);
            }
            $data = array('type' => 'php', 'title' => $function, 'syntax' => !empty($syntax) ? $syntax : '', 'params' => !empty($params) ? $params : '', 'desc' => !empty($description) ? $description : '', 'returns' => !empty($returns) ? $returns : '', 'href' => 'http://{{LANG}}.php.net/' . $function);
            break;
            // C
        // C
        case 'c':
            $function = preg_replace('/[^A-Za-z0-9_]/', '', $query);
            $href = "http://www.elook.org/programming/c/{$function}.html";
            $content = HTTP::get($href);
            // grab info from manual page
            $syntax = wfLimitText('<i>Syntax:</i>', '</pre>', $content);
            if (!empty($syntax)) {
                $syntax = trim(strip_tags($syntax));
            }
            $description = wfLimitText('<i>Description:</i>', '<br /><br />', $content);
            if (!empty($description)) {
                $description = trim(strip_tags($description, '<br><pre>'), "\n. ");
                $description = preg_replace('/(\\s+)/', ' ', $description);
            }
            $data = array('type' => 'c', 'title' => $function, 'syntax' => !empty($syntax) ? $syntax : '', 'desc' => !empty($description) ? $description : '', 'href' => $href);
            break;
            // man page
        // man page
        case 'man':
            $cmd = preg_replace('/[^A-Za-z0-9_]/', '', $query);
            $href = 'http://unixhelp.ed.ac.uk/CGI/man-cgi?' . $cmd;
            $content = HTTP::get($href);
            //echo '<pre>'.htmlspecialchars($content).'</pre>';
            // grab info from manual page
            $description = wfLimitText('<PRE>', '</PRE>', $content);
            if (!empty($description)) {
                $description = wfLimitText("\n", "\n", $description);
                $description = trim(strip_tags($description, '<h2>'));
                $description = substr($description, 0, -40);
                // keep headers formatted
                $description = strtr($description, array('<H2>' => '<b>', '</H2>' => '</b>'));
            }
            $data = array('type' => 'man', 'title' => $cmd, 'desc' => !empty($description) ? $description : '', 'href' => $href);
            break;
        default:
            return '';
    }
//.........这里部分代码省略.........
开发者ID:nomaan-alkurn,项目名称:thooth,代码行数:101,代码来源:app_scripts.php


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