PHP Classes
elePHPant
Icontem

HTTP Retriever: HTTP client to access Web servers

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2006-05-15 (10 years ago) RSS 2.0 feedStarStarStarStar 65%Total: 5,003 All time: 509 This week: 802Down
Version License Categories
httpretriever 1.0.0GNU General Publi...Networking, HTTP
Description Author

This class can be used to access Web servers using the HTTP protocol.

It supports:

- HTTP specification version 1.1
- Submit HTTP requests of method GET, POST or custom
- Access sites via SSL using PHP OpenSSL extension or CURL
- HTTP basic authentication
- Handle redirection automatically
- Cache retrieved pages for a given period
- Invoke callback functions during the connection progress

Name: Helmut Daschnigrum <contact>
Classes: 6 packages by
Country: Canada Canada
Age: ???
All time rank: 1007 in Canada Canada
Week rank: 418 Down8 in Canada Canada Down
Innovation award
Innovation award
Nominee: 1x

Details
HTTP Retriever
Version v1.1.7
Copyright 2004-2006, Steve Blinch
http://code.blitzaffe.com
============================================================================

DESCRIPTION

Provides a pure-PHP implementation of an HTTP v1.1 client, including support
for chunked transfer encoding and user agent spoofing.  Both GET and POST
requests are supported.

This can be used in place of something like CURL or WGET for HTTP requests.
Native SSL (HTTPS) requests are also supported if the OpenSSL extension is
installed under PHP v4.3.0 or greater.

If native SSL support is not available, the class will also check for the
CURL extension; if it's installed, it will transparently be used for SSL
(HTTPS) requests.

If neither native SSL support nor the CURL extension are available, and
libcurlemu (a CURL emulation library available from our web site) is found,
the class will also check for the CURL console binary (usually in
/usr/bin/curl); if it's installed, it will transparently be used for SSL
requests.

In short, if it's possible to make an HTTP/HTTPS request from your server,
this class can most likely do it.


HISTORY

1.1.7 (18-Apr-2006)
- Added support for automatically following HTTP redirects
- Added ::get_error() method to get any available error message (be
it an HTTP result error or an internal/connection error)
- Added ::cache_hit variable to determine whether the page was cached

1.1.6 (04-Mar-2006)
- Added stream_timeout class variable.
- Added progress_callback class variable.
- Added support for braindead servers that ignore Connection: close


EXAMPLE

// HTTPRetriever usage example
require_once("class_HTTPRetriever.php");
$http = &new HTTPRetriever();


// Example GET request:
// ----------------------------------------------------------------------------
$keyword = "blitzaffe code"; // search Google for this keyword
if (!$http->get("http://www.google.com/search?hl=en&q=%22".urlencode($keyword)."%22&btnG=Search&meta=")) {
echo "HTTP request error: #{$http->result_code}: {$http->result_text}";
return false;
}
echo "HTTP response headers:<br><pre>";
var_dump($http->response_headers);
echo "</pre><br>";

echo "Page content:<br><pre>";
echo $http->response;
echo "</pre>";
// ----------------------------------------------------------------------------


// Example POST request:
// ----------------------------------------------------------------------------
$keyword = "blitzaffe code"; // search Google for this keyword
$values = array(
"hl"=>"en",
"q"=>"%22".urlencode($keyword)."%22",
"btnG"=>"Search",
"meta"=>""
);
// Note: This example is just to demonstrate the POST equivalent of the GET
// example above; running this script will return a 501 Not Implemented, as
// Google does not support POST requests.
if (!$http->post("http://www.google.com/search",$http->make_query_string($values))) {
echo "HTTP request error: #{$http->result_code}: {$http->result_text}";
return false;
}
echo "HTTP response headers:<br><pre>";
var_dump($http->response_headers);
echo "</pre><br>";

echo "Page content:<br><pre>";
echo $http->response;
echo "</pre>";
// ----------------------------------------------------------------------------


LICENSE

This script is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This script is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along
with this script; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  Files folder image Files  
File Role Description
Plain text file class_HTTPRetriever.php Class Main HTTPRetriever class
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License terms
Accessible without login Plain text file README Doc. Documentation

 Version Control Reuses Unique User Downloads Download Rankings  
 0%3
Total:5,003
This week:0
All time:509
This week:802Down
User Ratings User Comments (2)
 All time
Utility:84%StarStarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:75%StarStarStarStar
Examples:78%StarStarStarStar
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:653