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


PHP HTTP_Request::getResponseBody方法代码示例

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


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

示例1: save

 function save($data)
 {
     if (!$data['GA_optin']) {
         trigger_error('did not opt to join');
         return true;
     }
     $options = $this->getOptions();
     $request = new HTTP_Request($options['hostname'] . '/offsite-join.tcl');
     $request->setMethod(HTTP_REQUEST_METHOD_POST);
     $request->addPostData('domain', $options['domain']);
     if ($options['source']) {
         $request->addPostData('source', $options['source']);
     }
     if ($options['update']) {
         $request->addPostData('update', $options['update']);
     }
     foreach ($this->translate($data) as $name => $value) {
         $request->addPostData($name, $value);
     }
     if (!PEAR::isError($request->sendRequest())) {
         $message = trim($request->getResponseBody());
         if ('OK' == $message) {
             return true;
         } else {
             $this->ERROR = $message;
             trigger_error($message);
             return false;
         }
     }
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:30,代码来源:Save.inc.php

示例2: retrieveFile

 /**
  * Retrieves data from cache, if it's there.  If it is, but it's expired,
  * it performs a conditional GET to see if the data is updated.  If it
  * isn't, it down updates the modification time of the cache file and
  * returns the data.  If the cache is not there, or the remote file has been
  * modified, it is downloaded and cached.
  *
  * @param string URL of remote file to retrieve
  * @param int Length of time to cache file locally before asking the server
  *            if it changed.
  * @return string File contents
  */
 function retrieveFile($url, $cacheLength, $cacheDir)
 {
     $cacheID = md5($url);
     $cache = new Cache_Lite(array("cacheDir" => $cacheDir, "lifeTime" => $cacheLength));
     if ($data = $cache->get($cacheID)) {
         return $data;
     } else {
         // we need to perform a request, so include HTTP_Request
         include_once 'HTTP/Request.php';
         // HTTP_Request has moronic redirect "handling", turn that off (Alexey Borzov)
         $req = new HTTP_Request($url, array('allowRedirects' => false));
         // if $cache->get($cacheID) found the file, but it was expired,
         // $cache->_file will exist
         if (isset($cache->_file) && file_exists($cache->_file)) {
             $req->addHeader('If-Modified-Since', gmdate("D, d M Y H:i:s", filemtime($cache->_file)) . " GMT");
         }
         $req->sendRequest();
         if (!($req->getResponseCode() == 304)) {
             // data is changed, so save it to cache
             $data = $req->getResponseBody();
             $cache->save($data, $cacheID);
             return $data;
         } else {
             // retrieve the data, since the first time we did this failed
             if ($data = $cache->get($cacheID, 'default', true)) {
                 return $data;
             }
         }
     }
     Services_ExchangeRates::raiseError("Unable to retrieve file {$url} (unknown reason)", SERVICES_EXCHANGERATES_ERROR_RETRIEVAL_FAILED);
     return false;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:44,代码来源:Common.php

示例3: setInputFile

 /**
  * Sets the input xml file to be parsed
  *
  * @access  public
  * @param   string  $file  Filename(full path)
  * @return  mixed   True on success or error on failure
  */
 function setInputFile($file)
 {
     require_once PEAR_PATH . 'HTTP/Request.php';
     $httpRequest = new HTTP_Request($file, $this->_params);
     $httpRequest->setMethod(HTTP_REQUEST_METHOD_GET);
     $resRequest = $httpRequest->sendRequest();
     if (PEAR::isError($resRequest)) {
         return $resRequest;
     } elseif ($httpRequest->getResponseCode() != 200) {
         return $this->raiseError('HTTP response error', HTTP_REQUEST_ERROR_RESPONSE);
     }
     $data = trim($httpRequest->getResponseBody());
     if (version_compare(PHP_VERSION, '5.0.0', '<')) {
         if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $data, $matches)) {
             $srcenc = strtoupper($matches[1]);
             if (!in_array($srcenc, $this->_validEncodings)) {
                 if (function_exists('iconv')) {
                     $data = @iconv($srcenc, 'UTF-8', $data);
                 } elseif (function_exists('mb_list_encodings') && in_array($srcenc, array_map('strtoupper', mb_list_encodings()))) {
                     $data = @mb_convert_encoding($data, 'UTF-8', $srcenc);
                 }
             }
         }
     }
     $this->setInputString($data);
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:34,代码来源:XML_Feed.php

示例4: getrss

 /**
  * getRSS
  * 
  * @access protected
  */
 protected function getrss($url)
 {
     require_once 'HTTP/Request.php';
     $req = new HTTP_Request($url, array('timeout' => 4, 'readTimeout' => array(4, 0)));
     $result = $req->sendRequest();
     if (PEAR::isError($result)) {
         $mes = htmlspecialchars($result->getMessage());
         return "<p class=\"warning\">RSSを読み込めません({$mes})。</p>";
     }
     $xml = @simplexml_load_string($req->getResponseBody());
     if ($xml === false) {
         return '<p class="warning">RSSを解釈できません。</p>';
     }
     $ret[] = '<ul class="plugin_rss">';
     foreach ($xml->item as $item) {
         /**
          * Namespace付きの子要素を取得
          * この場合、<dc:date>要素が対象
          */
         $dc = $item->children('http://purl.org/dc/elements/1.1/');
         $date = isset($dc->date) ? '&nbsp;(' . date('Y-m-d H:i', strtotime($dc->date)) . ')' : '';
         $_link = htmlspecialchars($item->link);
         $_title = htmlspecialchars(mb_convert_encoding($item->title, 'UTF-8', 'auto'));
         $line = '<li>';
         $line .= "<a href=\"{$_link}\">{$_title}</a>" . $date;
         $line .= '</li>';
         $ret[] = $line;
     }
     $ret[] = '</ul>';
     return join("\n", $ret);
 }
开发者ID:riaf,项目名称:kinowiki,代码行数:36,代码来源:rss.inc.php

示例5: fetchData

 function fetchData($username, $password)
 {
     switch ($this->options['cryptType']) {
         case 'blowfish':
             include_once 'Crypt/Blowfish.php';
             $bf = new Crypt_Blowfish($this->options['cryptKey']);
             $password = $bf->encrypt($password);
             $password = base64_encode($password);
             break;
         default:
             if (function_exists($this->options['cryptType'])) {
                 $password = $this->options['cryptType']($password);
             }
             break;
     }
     $req = new HTTP_Request();
     $req->setURL($this->options['URL']);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     $req->addQueryString($this->options['usernameKey'], $username);
     $req->addQueryString($this->options['passwordKey'], $password);
     if (!PEAR::isError($req->sendRequest())) {
         $response = $req->getResponseBody();
     } else {
         return false;
     }
     $unserializer = new XML_Unserializer();
     if ($unserializer->unserialize($response)) {
         $this->result_value = $unserializer->getUnserializedData();
         if ($this->result_value[$this->options['resultKey']] == $this->options['correctValue']) {
             return true;
         }
     }
     return false;
 }
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:34,代码来源:REST_XML.php

示例6: versionCheck

 /**
  * versionCheck - Get the most current version of nterchange and cache the result.
  *
  * @return 	array 	Information about the newest version of nterchange.
  **/
 function versionCheck()
 {
     require_once 'Cache/Lite.php';
     $options = array('cacheDir' => CACHE_DIR . '/ntercache/', 'lifeTime' => $this->check_version_interval);
     $cache = new Cache_Lite($options);
     $yaml = $cache->get($this->cache_name, $this->cache_group);
     if (empty($yaml)) {
         include_once 'HTTP/Request.php';
         $req = new HTTP_Request($this->check_version_url);
         if (!PEAR::isError($req->sendRequest())) {
             $yaml = $req->getResponseBody();
             $cached = $cache->save($yaml, $this->cache_name, $this->cache_group);
             if ($cached == true) {
                 NDebug::debug('Version check - data is from the web and is now cached.', N_DEBUGTYPE_INFO);
             } else {
                 NDebug::debug('Version check - data is from the web and is NOT cached.', N_DEBUGTYPE_INFO);
             }
         }
     } else {
         NDebug::debug('Version check - data is from the cache.', N_DEBUGTYPE_INFO);
     }
     require_once 'vendor/spyc.php';
     $newest_version_info = @Spyc::YAMLLoad($yaml);
     return $newest_version_info;
 }
开发者ID:nonfiction,项目名称:nterchange,代码行数:30,代码来源:version_check_controller.php

示例7: shorten

 public function shorten($url, $text)
 {
     $req = new HTTP_Request($this->apiurl . '?url=' . urlencode($url) . "&text=" . urlencode($text) . "&maxchars=120");
     if (!PEAR::isError($req->sendRequest())) {
         return json_decode($req->getResponseBody(), true);
     }
     return "";
 }
开发者ID:vijo,项目名称:rss2twi.php,代码行数:8,代码来源:splanetphp.php

示例8: shorten

 public function shorten($url)
 {
     $req = new HTTP_Request($this->apiurl . urlencode($url));
     if (!PEAR::isError($req->sendRequest())) {
         return $req->getResponseBody();
     }
     return "";
 }
开发者ID:vijo,项目名称:rss2twi.php,代码行数:8,代码来源:isgd.php

示例9: call

 /**
  * @throws BadRequestException
  * @param  $method
  * @param  $args
  * @return mixed
  */
 public function call($method, $args)
 {
     $req = new HTTP_Request($this->conf->endpoint . $method);
     $req->setMethod('POST');
     $args['app_id'] = $this->conf->app_id;
     foreach ($args as $key => $value) {
         $req->addPostData($key, $value);
     }
     $sig = sign($args, $this->conf->key);
     $req->addPostData('signature', $sig['signature']);
     $req->addPostData('time', $sig['time']);
     $req->sendRequest();
     if ($req->getResponseCode() != 200) {
         throw new BadRequestException($req->getResponseBody());
     }
     return json_decode($req->getResponseBody());
 }
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:23,代码来源:client.php

示例10: _fetch

 /**
  * Helper function to fetch HTTP-URLs
  *
  * @param string $url
  * @return string
  * @todo Error handling is missing
  */
 protected function _fetch($url)
 {
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
     $request = new HTTP_Request($url);
     $request->setMethod(HTTP_REQUEST_METHOD_GET);
     $request->sendRequest();
     return $request->getResponseBody();
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:15,代码来源:abstract.php

示例11: doSearch

 function doSearch($url)
 {
     $req = new HTTP_Request($url);
     $req->sendRequest();
     $contents = $req->getResponseBody();
     if (!xml_parse($this->_parser, $contents)) {
         die(sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser)));
     }
     xml_parser_free($this->_parser);
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:10,代码来源:AmazonSearchEngine.class.php

示例12:

 /**
  * serendipity_plugin_zooomr::getURL()
  * downloads the content from an URL and returns it as a string
  *
  * @author Stefan Lange-Hegermann
  * @since 02.08.2006
  * @param string $url URL to get
  * @return string downloaded Data from "$url"
  */
 function get_url($url)
 {
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
     $req = new HTTP_Request($url);
     if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
         $store = file_get_contents($url);
     } else {
         $store = $req->getResponseBody();
     }
     return $store;
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:20,代码来源:serendipity_plugin_zooomr.php

示例13: sendRequest

 function sendRequest($return_body = true)
 {
     $this->Response = $this->HttpRequest->sendRequest();
     $this->code = $this->HttpRequest->getResponseCode();
     if (PEAR::isError($this->Response)) {
         $this->error = $this->Response->getMessage();
         return false;
     } else {
         return $return_body ? $this->HttpRequest->getResponseBody() : true;
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:11,代码来源:AkHttpClient.php

示例14: getPostUrl

 /**
  * 投稿するためのURL取得
  */
 protected function getPostUrl()
 {
     $hr = new HTTP_Request($this->atomapi_url);
     $hr->addHeader('X-WSSE', $this->wsse);
     $hr->addHeader('Accept', 'application/x.atom+xml, application/xml, text/xml, */*');
     $hr->addHeader('Authorization', 'WSSE profile="UsernameToken"');
     $hr->addHeader('Content-Type', 'application/x.atom+xml');
     $hr->sendRequest();
     $res = $hr->getResponseBody();
     $xml = simplexml_load_string($res);
     return (string) $xml->link[0]->attributes()->href;
 }
开发者ID:youg0717,项目名称:ameblo,代码行数:15,代码来源:Ameblo.php

示例15: getURL

 /**
  *
  */
 function getURL($url)
 {
     require_once PEAR_PATH . 'HTTP/Request.php';
     $httpRequest = new HTTP_Request($url);
     $httpRequest->setMethod(HTTP_REQUEST_METHOD_GET);
     $resRequest = $httpRequest->sendRequest();
     if (!PEAR::isError($resRequest) && $httpRequest->getResponseCode() == 200) {
         $data = $httpRequest->getResponseBody();
     } else {
         $data = @file_get_contents($url);
     }
     return $data;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:16,代码来源:AddressProtector.php


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