PHP code example of clox / hicurl

1. Go to this page and download the library: Download clox/hicurl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

clox / hicurl example snippets




$hicurl=new Hicurl();
$google=$hicurl->loadSingle('www.google.com');
The $google-variable will now hold an associative array looking like:  
[
    'content'=>page-content  
    ,'headers'=>all the received headers  
    ,'error'=>false for success, otherwise a description of the error
]


$hicurl=new Hicurl();
$hicurl->loadSingle('http://www.htmlcodetutorial.com/cgi-bin/mycgi.pl',['foo'=>'bar']);

$hicurl=new Hicurl(['cookie'=>'cookies/cookie.txt']);  

$hicurl->settings(['cookie'=>'cookies/muffin.txt']);

$hicurl->loadSingle('www.google.com',null,['cookie'=>'cookies/macarone.txt']);

$result=Hicurl->loadSingleStatic($url,$postData,['cookie'=>'cake.txt']);

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLINFO_HEADER_OUT,true);
curl_setopt($ch,CURLOPT_COOKIEFILE],'cake.txt');
curl_setopt($ch,CURLOPT_COOKIEJAR]'cake.txt');
$postDataString="";
foreach ($postData as $key=>$value) {
    $postDataString.=urlencode($key)."=".urlencode($value)."&";
}
curl_setopt($ch,CURLOPT_POSTFIELDS, trim($string, ","));
$result=['content'=>curl_exec($ch),'headers'=>curl_getinfo($ch)];
curl_close($ch);

//set a history output filepath. This setting will be used for subsequent load-calls and will make them save data to that file.
$hicurl->settings(['history'=>'history/myHistoryFile']);
//load a couple pages. they will be saved to myHistoryFile
$hicurl->loadSingle("www.google.com");
$hicurl->loadSingle("www.facebook.com");
//When we are done writing to the file we need to "compile it".
//This puts it in a closed state, and also compresses it.
//This is the state it is sent to the client in.
$hicurl->compileHistory();


Hicurl::serveHistory('history/myHistoryFile');