

HttpClient Home | Download HttpClient (txt) | HttpClient Manual | HttpClient Examples
This demo (which may take a few seconds to load) attempts to retrieves the front page of Amazon.com and reports its size in bytes. Debug mode is switched on to show what the script is doing. This demonstrates the script automatically following redirections and maintaining cookies and referrers between sessions.
$client = new HttpClient('www.amazon.com');
$client->setDebug(true);
if (!$client->get('/')) {
echo '<p>Request failed!</p>';
} else {
echo '<p>Amazon home page is '.strlen($client->getContent()).' bytes.</p>';
}
GET / HTTP/1.0 Host: www.amazon.com User-Agent: Incutio HttpClient v0.9 Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/* Accept-encoding: gzip Accept-language: en-us
Array
(
[date] => Wed, 14 May 2008 03:55:45 GMT
[server] => Server
[set-cookie] => Array
(
[0] => skin=noskin; path=/; domain=.amazon.com; expires=Wed, 14-May-2008 03:55:45 GMT
[1] => session-id-time=1211266800l; path=/; domain=.amazon.com; expires=Tue May 20 07:00:00 2008 GMT
[2] => session-id=002-6761096-1776039; path=/; domain=.amazon.com; expires=Tue May 20 07:00:00 2008 GMT
)
[x-amz-id-1] => 0HEHPMCVK0H7PYK5RDF4
[x-amz-id-2] => eSDZYdI0MAhUB9jNzpRmxv6DY9VLz0bD
[vary] => Accept-Encoding,User-Agent
[content-encoding] => gzip
[content-type] => text/html; charset=ISO-8859-1
[connection] => close
)
Amazon home page is 150970 bytes
