

HttpClient Home | Download HttpClient (tar.gz) | 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] => Fri, 10 Feb 2012 00:49:42 GMT
[server] => Server
[set-cookie] => Array
(
[0] => skin=noskin; path=/; domain=.amazon.com; expires=Fri, 10-Feb-2012 00:49:42 GMT
[1] => session-id-time=2082787201l; path=/; domain=.amazon.com; expires=Tue, 01-Jan-2036 08:00:01 GMT
[2] => session-id=190-2689780-8851632; path=/; domain=.amazon.com; expires=Tue, 01-Jan-2036 08:00:01 GMT
)
[pragma] => no-cache
[x-amz-id-1] => 0X3MEMWQEY95ZS0AS2RS
[p3p] => policyref="http://www.amazon.com/w3c/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "
[cache-control] => no-cache
[expires] => -1
[x-amz-id-2] => MuTRFvIW7prjA7xK3ze8OJUerD2RShqb+v8CfNdNez2x5jegtfJ7JFlYxtC4qMKb
[vary] => Accept-Encoding,User-Agent
[content-encoding] => gzip
[content-type] => text/html; charset=ISO-8859-1
[connection] => close
)
Amazon home page is 115841 bytes
