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


PHP HttpClient::get方法代码示例

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


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

示例1: crawlerProgramItems

 static function crawlerProgramItems($date, $chnnel)
 {
     $url = replaceStr(CnTVLiveParse::BASE_EPISODE, '{DATE}', $date);
     $url = replaceStr($url, '{TV_CODE}', $chnnel);
     $client = new HttpClient('tv.cntv.cn');
     $client->get('/epg');
     $client->get($url);
     writetofile("program_live_item_crawler.log", "url:[http://tv.cntv.cn" . $url . "]");
     $content = $client->getContent();
     return CnTVLiveParse::parseMovieInfoByContent($content, $p_code, $type);
 }
开发者ID:andyongithub,项目名称:joyplus-cms,代码行数:11,代码来源:CnTVLiveParse.php

示例2: download

 /**
  * @param Url $url
  *
  * @return File
  * @throws DownloadFailedException
  */
 public function download(Url $url)
 {
     $this->output->writeInfo(sprintf('Downloading %s', $url));
     $response = $this->curl->get($url);
     if ($response->getHttpCode() !== 200) {
         throw new DownloadFailedException(sprintf('Download failed (HTTP status code %s) %s', $response->getHttpCode(), $response->getErrorMessage()));
     }
     if (empty($response->getBody())) {
         throw new DownloadFailedException('Download failed - response is empty');
     }
     return new File($this->getFilename($url), $response->getBody());
 }
开发者ID:Flyingmana,项目名称:phive,代码行数:18,代码来源:FileDownloader.php

示例3: download

 /**
  * @param string $keyId
  *
  * @return string
  * @throws DownloadFailedException
  */
 public function download($keyId)
 {
     $params = ['search' => '0x' . $keyId, 'op' => 'get', 'options' => 'mr'];
     foreach ($this->keyServers as $keyServer) {
         $this->output->writeInfo(sprintf('Trying %s', $keyServer));
         $result = $this->httpClient->get(new Url($keyServer . self::PATH), $params);
         if ($result->getHttpCode() == 200) {
             $this->output->writeInfo('Sucessfully downloaded key');
             return $result->getBody();
         }
         $this->output->writeWarning(sprintf('Failed with status code %s: %s', $result->getHttpCode(), $result->getErrorMessage()));
     }
     throw new DownloadFailedException(sprintf('Key %s not found on key servers', $keyId));
 }
开发者ID:Flyingmana,项目名称:phive,代码行数:20,代码来源:GnupgKeyDownloader.php

示例4: testEffectiveUrl

 /**
  * @dataProvider effectiveUrls
  */
 public function testEffectiveUrl($url, $expected, $params = array())
 {
     $http = new HttpClient();
     $http->get($url, $params);
     $this->assertEquals($expected, $http->getEffectiveUrl());
     $this->assertEquals($expected, $http->effectiveUrl);
 }
开发者ID:urmaul,项目名称:httpclient,代码行数:10,代码来源:InfoTest.php

示例5: http_get_file

function http_get_file($url)
{
    $httpClient = new HttpClient("epub.cnki.net");
    $httpClient->get($url);
    $content = $httpClient->getContent();
    return $content;
}
开发者ID:highestgoodlikewater,项目名称:cnkispider,代码行数:7,代码来源:index.php

示例6: fetch

 /**
  * Uses httpClient to fetch results and map to an object of type $className
  * 
  * @param string $url
  * @param string $className
  * @return obj
  */
 private function fetch($url, $className)
 {
     $key = sha1($url);
     if (!isset($this->cache[$key])) {
         $xml = $this->httpClient->get($url);
         $this->cache[$key] = call_user_func_array(array($className, 'createFromXml'), array($xml, $this));
     }
     return $this->cache[$key];
 }
开发者ID:verticaltab,项目名称:pillow,代码行数:16,代码来源:Service.php

示例7: processFeed

 /**
  * @param Feed $feed
  */
 public function processFeed($feed)
 {
     $http = new \HttpClient();
     $body = $http->get($this->url);
     if ($body !== false) {
         $this->parseBody($body, $feed);
     } elseif ($this->showErrors) {
         $feed->addItem(['title' => $http->lastError, 'link' => $this->url]);
     }
 }
开发者ID:urmaul,项目名称:rss-pipes,代码行数:13,代码来源:Rss.php

示例8: HttpClient

 function _loadVersion()
 {
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'httpclient.class.php';
     $client = new HttpClient('www.easy-joomla.org');
     if (!$client->get('/components/com_versions/directinfo.php?catid=3')) {
         $this->setError($client->getError());
         return false;
     }
     $this->_current = $client->getContent();
     return true;
 }
开发者ID:hrishikesh-kumar,项目名称:NBSNIP,代码行数:11,代码来源:version.php

示例9: download

 /**
  * download a media
  * @param string $filename - file for downloading to
  * @param string $mediaId - mediaId of file
  * @param bool $https(optional default true) - if downloading video-type file, 
  *		set $https to false for http request
  * @return int - filesize of the media or string - json for error message(if error)
  */
 public function download($filename, $mediaId, $https = true)
 {
     if ($https) {
         $client = new HttpClient("https://api.weixin.qq.com/cgi-bin/media/get?access_token={$this->access_token}&media_id={$mediaId}");
     } else {
         $client = new HttpClient("http://api.weixin.qq.com/cgi-bin/media/get?access_token={$this->access_token}&media_id={$mediaId}");
     }
     $client->get();
     if ($client->getState() == 200) {
         if (!is_null(json_decode($client->getResponse()))) {
             //data of json format(error here)
             return $client->getResponse();
         } else {
             file_put_contents($filename, $client->getResponse());
             return filesize($filename);
         }
     } else {
         return false;
     }
 }
开发者ID:jianhua1982,项目名称:wlight,代码行数:28,代码来源:media.php

示例10: fixProfile

function fixProfile($uri)
{
    $oprofile = Ostatus_profile::getKV('uri', $uri);
    if (!$oprofile) {
        print "No OStatus remote profile known for URI {$uri}\n";
        return false;
    }
    echo "Before:\n";
    showProfileInfo($oprofile);
    $feedurl = $oprofile->feeduri;
    $client = new HttpClient();
    $response = $client->get($feedurl);
    if ($response->isOk()) {
        echo "Updating profile from feed: {$feedurl}\n";
        $dom = new DOMDocument();
        if ($dom->loadXML($response->getBody())) {
            $feed = $dom->documentElement;
            $entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry');
            if ($entries->length) {
                $entry = $entries->item(0);
                $activity = new Activity($entry, $feed);
                $oprofile->checkAuthorship($activity);
                echo "  (ok)\n";
            } else {
                echo "  (no entry; skipping)\n";
                return false;
            }
        } else {
            echo "  (bad feed; skipping)\n";
            return false;
        }
    } else {
        echo "Failed feed fetch: {$response->getStatus()} for {$feedurl}\n";
        return false;
    }
    echo "After:\n";
    showProfileInfo($oprofile);
    return true;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:39,代码来源:update-profile-data.php

示例11: checkPass

 /**
  * Preferences are handled in _PassUser
  */
 function checkPass($password)
 {
     $userid = $this->_userid;
     if (!loadPhpExtension('openssl')) {
         trigger_error(sprintf(_("The PECL %s extension cannot be loaded."), "openssl") . sprintf(_(" %s AUTH ignored."), 'Facebook'), E_USER_WARNING);
         return $this->_tryNextUser();
     }
     $web = new HttpClient("www.facebook.com", 80);
     if (DEBUG & _DEBUG_LOGIN) {
         $web->setDebug(true);
     }
     // collect cookies from http://www.facebook.com/login.php
     $web->persist_cookies = true;
     $web->cookie_host = 'www.facebook.com';
     $firstlogin = $web->get("/login.php");
     if (!$firstlogin) {
         if (DEBUG & (_DEBUG_LOGIN | _DEBUG_VERBOSE)) {
             trigger_error(sprintf(_("Facebook connect failed with %d %s"), $web->status, $web->errormsg), E_USER_WARNING);
         }
     }
     // Switch from http to https://login.facebook.com/login.php
     $web->port = 443;
     $web->host = 'login.facebook.com';
     if (!($retval = $web->post("/login.php", array('user' => $userid, 'pass' => $password)))) {
         if (DEBUG & (_DEBUG_LOGIN | _DEBUG_VERBOSE)) {
             trigger_error(sprintf(_("Facebook login failed with %d %s"), $web->status, $web->errormsg), E_USER_WARNING);
         }
     }
     $this->_authmethod = 'Facebook';
     if (DEBUG & _DEBUG_LOGIN) {
         trigger_error(get_class($this) . "::checkPass => {$retval}", E_USER_WARNING);
     }
     if ($retval) {
         $this->_level = WIKIAUTH_USER;
     } else {
         $this->_level = WIKIAUTH_ANON;
     }
     return $this->_level;
 }
开发者ID:hugcoday,项目名称:wiki,代码行数:42,代码来源:Facebook.php

示例12: preLogUser

 function preLogUser($sessionId)
 {
     require_once AJXP_BIN_FOLDER . "/class.HttpClient.php";
     $client = new HttpClient($this->getOption("REMOTE_SERVER"), $this->getOption("REMOTE_PORT"));
     $client->setDebug(false);
     if ($this->getOption("REMOTE_USER") != "") {
         $client->setAuthorization($this->getOption("REMOTE_USER"), $this->getOption("REMOTE_PASSWORD"));
     }
     $client->setCookies(array($this->getOption("REMOTE_SESSION_NAME") ? $this->getOption("REMOTE_SESSION_NAME") : "PHPSESSID" => $sessionId));
     $result = $client->get($this->getOption("REMOTE_URL"), array("session_id" => $sessionId));
     if ($result) {
         $user = $client->getContent();
         if ($this->autoCreateUser()) {
             AuthService::logUser($user, "", true);
         } else {
             // If not auto-create but the user exists, log him.
             if ($this->userExists($user)) {
                 AuthService::logUser($user, "", true);
             }
         }
     }
 }
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:22,代码来源:class.remote_ajxpAuthDriver.php

示例13: test

 public function test()
 {
     $request = ['url' => 'http://thegamesdb.net/api/GetGame.php', 'params' => ['name' => 'harry potter']];
     $response = \HttpClient::get($request);
     dd(\Parser::xml($response->content()));
 }
开发者ID:dmartinng,项目名称:gamesforstuff,代码行数:6,代码来源:PagesController.php

示例14: installSlicer

function installSlicer($version, $installDir, $filename, $quiet, $disableTls, $cafile)
{
    $installPath = (is_dir($installDir) ? rtrim($installDir, '/') . '/' : '') . $filename;
    $installDir = realpath($installDir) ? realpath($installDir) : getcwd();
    $file = $installDir . DIRECTORY_SEPARATOR . $filename;
    if (is_readable($file)) {
        @unlink($file);
    }
    if (FALSE === $disableTls && empty($cafile) && !HttpClient::getSystemCaRootBundlePath()) {
        $errorHandler = new ErrorHandler();
        set_error_handler([$errorHandler, 'handleError']);
        $home = getenv('COMPOSER_HOME');
        if (!$home) {
            if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                if (!getenv('APPDATA')) {
                    throw new RuntimeException('The APPDATA or SLICER_HOME environment variable must be set for composer to install correctly');
                }
                $home = strtr(getenv('APPDATA'), '\\', '/') . '/Slicer';
            } else {
                if (!getenv('HOME')) {
                    throw new RuntimeException('The HOME or SLICER_HOME environment variable must be set for composer to install correctly');
                }
                $home = rtrim(getenv('HOME'), '/') . '/.slicer';
            }
        }
        $target = $home . '/cacert.pem';
        if (!is_dir($home)) {
            @mkdir($home, 0777, TRUE);
        }
        $write = file_put_contents($target, HttpClient::getPackagedCaFile(), LOCK_EX);
        @chmod($target, 0644);
        restore_error_handler();
        if (!$write) {
            throw new RuntimeException('Unable to write bundled cacert.pem to: ' . $target);
        }
        $cafile = $target;
    }
    $httpClient = new HttpClient($disableTls, $cafile);
    $retries = 3;
    while ($retries--) {
        if (!$quiet) {
            out("Downloading...", 'info');
        }
        $uriScheme = FALSE === $disableTls ? 'https' : 'http';
        $urlPath = (FALSE !== $version ? "/download/{$version}" : '') . '/slicer.phar';
        $url = "{$uriScheme}://getslicer.com{$urlPath}";
        $errorHandler = new ErrorHandler();
        set_error_handler([$errorHandler, 'handleError']);
        $fh = fopen($file, 'w');
        if (!$fh) {
            out('Could not create file ' . $file . ': ' . $errorHandler->message, 'error');
        }
        if (!fwrite($fh, $httpClient->get($url))) {
            out('Download failed: ' . $errorHandler->message, 'error');
        }
        fclose($fh);
        restore_error_handler();
        if ($errorHandler->message) {
            continue;
        }
        try {
            // create a temp file ending in .phar since the Phar class only accepts that
            if ('.phar' !== substr($file, -5)) {
                copy($file, $file . '.tmp.phar');
                $pharFile = $file . '.tmp.phar';
            } else {
                $pharFile = $file;
            }
            if (!ini_get('phar.readonly')) {
                // test the phar validity
                $phar = new Phar($pharFile);
                // free the variable to unlock the file
                unset($phar);
            }
            // clean up temp file if needed
            if ($file !== $pharFile) {
                unlink($pharFile);
            }
            break;
        } catch (Exception $e) {
            if (!$e instanceof UnexpectedValueException && !$e instanceof PharException) {
                throw $e;
            }
            // clean up temp file if needed
            if ($file !== $pharFile) {
                unlink($pharFile);
            }
            unlink($file);
            if ($retries) {
                if (!$quiet) {
                    out('The download is corrupt, retrying...', 'error');
                }
            } else {
                out('The download is corrupt (' . $e->getMessage() . '), aborting.', 'error');
                exit(1);
            }
        }
    }
    if ($errorHandler->message) {
        out('The download failed repeatedly, aborting.', 'error');
//.........这里部分代码省略.........
开发者ID:rawphp,项目名称:slicer,代码行数:101,代码来源:installer.php

示例15: onConnect

 public function onConnect(IWebSocketConnection $user)
 {
     if ($user->getAdminKey() == self::$ADMIN_KEY) {
         $this->say("[ECHO] Admin user connected");
         return;
     }
     $h = $user->getHeaders();
     $c = WebSocketFunctions::cookie_parse($h["Cookie"]);
     $client = new HttpClient($this->host);
     $client->cookies = $c;
     $client->get("/{$this->path}/?get_action=ws_authenticate&key=" . self::$ADMIN_KEY);
     $registry = $client->getContent();
     //$this->say("[ECHO] Registry loaded".$registry);
     $xml = new DOMDocument();
     $xml->loadXML($registry);
     $xPath = new DOMXPath($xml);
     $err = $xPath->query("//message[@type='ERROR']");
     if ($err->length) {
         $this->say($err->item(0)->firstChild->nodeValue);
         $user->disconnect();
     } else {
         $userRepositories = array();
         $repos = $xPath->query("/tree/user/repositories/repo");
         foreach ($repos as $repo) {
             $repoId = $repo->attributes->getNamedItem("id")->nodeValue;
             $userRepositories[] = $repoId;
         }
         $user->ajxpRepositories = $userRepositories;
         $user->ajxpId = $xPath->query("/tree/user/@id")->item(0)->nodeValue;
         if ($xPath->query("/tree/user/@groupPath")->length) {
             $groupPath = $xPath->query("/tree/user/@groupPath")->item(0)->nodeValue;
             if (!empty($groupPath)) {
                 $user->ajxpGroupPath = $groupPath;
             }
         }
     }
     $this->say("[ECHO] User '" . $user->ajxpId . "' connected with " . count($user->ajxpRepositories) . " registered repositories ");
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:38,代码来源:ws-server.php


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