2017 © Pedro Peláez
 

library hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension.Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

image

clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension.Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  • Tuesday, April 26, 2016
  • by Clox
  • Repository
  • 1 Watchers
  • 0 Stars
  • 33 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 28 Versions
  • 0 % Grown

The README.md

Hicurl

A library that aims in making cURL-requests a piece of cake while also allowing for saving the fetched pages along with headers and postdata to files for later viewing. It essentially is a PHP wrapper class for cURL, and a javascript "class" that displays the saved data nicely., (*1)

Getting Started

Simple Usage

To use Hicurl on the PHP side you simply need to include hicurl.php inside the src folder:, (*2)

require_once 'hicurl/src/hicurl.php';

Then you can do something like the following to begin loading some pages:, (*3)

$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
]

It is also easy sending post-data. If an object is passed to the second parameter the request will be sent as POST with that data:, (*4)

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

Settings

There's a bunch of settings that can be used. These can be passed or like this:, (*5)

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

Any calls made with that instance will now save cookies in and send cookies from that file. Settings can be changed after instance-creation:, (*6)

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

Lastly, they may also be passed to the load call in which case they will be merged with the settings of the instance during that call only:, (*7)

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

Static usage

Most methods also have static counterparts which can be convenient if only a single call is to be made:, (*8)

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

It's equivalent without hicurl would be something along the lines of:, (*9)

$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);

"Whew!", (*10)

Saving history

Saving data is easy too. For starters we need one additional setting:, (*11)

//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();

Sending history

There's some easy job to be done for sending the data to the client. Here's one way of doing it:, (*12)

getHistory.php, (*13)

require_once 'hicurl/src/hicurl.php';
Hicurl::serveHistory('history/myHistoryFile');

That's what we need for sending the data. Though simply loading this page in the browser wont help much, so we will need to do the following..., (*14)

Viewing history

To be able to view the data in a meaningful way we will use the javascript hicurl-class. We need to load some files to use it and then write a tiny bit more code., (*15)

    <!--This is the js "class" used for viewing the history-->
    <script src="hicurl/src/hicurl.js"></script>

    <!--...it needs this css-file to display things correctly-->
    <link rel="stylesheet" type="text/css" href="hicurl/src/hicurl.css">

    <!--It also required jQuery-->
    <script src="hicurl/src/libs/jquery-1.11.2.min.js"></script>

    <!--.And jquery easy UI-->
    <script src="hicurl/src/libs/jquery.easyui.min.js"></script>

    <!--...along with it's css-file-->
    <link rel="stylesheet" type="text/css" href="../../src/libs/easyui.css">

    <!--This can optionally be included and will make html-code display better-->
    <script src="hicurl/src/libs/beautify-html.js"></script>

    <!--Now for initiating the class-->
    <script>
    //it expects a DOM-element in its first parameter, where everything will be rendered unto.
    //As second parameter we will need to pass a url-string where it will fetch the history-data from.
    hicurl=new Hicurl(document.body,"getMyHistory.php");
    //We will need to create that page, e.g. "getHistory.php" in this case,  and make it send the data.
    </script>

The Versions

26/04 2016

dev-prepare_for_v2

dev-prepare_for_v2 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension.Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

19/01 2016

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension.Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

13/01 2016

dev-complete_separating_customData_and_also_remove_static_methods

dev-complete_separating_customData_and_also_remove_static_methods https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension.Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

19/05 2015

dev-separate_customData_from_compile()

dev-separate_customData_from_compile() https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

11/05 2015

dev-Store_history_as_separate_files

dev-Store_history_as_separate_files https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

01/05 2015

v2.0.3-a

2.0.3.0-alpha https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

01/05 2015

v2.0.2-a

2.0.2.0-alpha https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

30/04 2015

v2.0.1-a

2.0.1.0-alpha https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

30/04 2015

v2.0.1

2.0.1.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

29/04 2015

v2.0.0-a

2.0.0.0-alpha https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

25/04 2015

dev-master

9999999-dev https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

25/04 2015

v1.6.0

1.6.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

23/04 2015

v1.5.0

1.5.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

22/04 2015

1.4.3

1.4.3.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

22/04 2015

v1.4.2

1.4.2.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

22/04 2015

v1.4.1

1.4.1.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

21/04 2015

v1.4.0

1.4.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

21/04 2015

v1.3.1

1.3.1.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

21/04 2015

v1.3.0

1.3.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

09/04 2015

v1.2.0

1.2.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

08/04 2015

v1.1.6

1.1.6.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

08/04 2015

v1.1.5

1.1.5.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

08/04 2015

v1.1.4

1.1.4.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

08/04 2015

v1.1.3

1.1.3.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

07/04 2015

v1.1.2

1.1.2.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

07/04 2015

v1.1.1

1.1.1.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

07/04 2015

v1.1.0

1.1.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save

07/04 2015

v1.0.0

1.0.0.0 https://github.com/Clox/hicurl

hicurl is an object-oriented wrapper of the PHP cURL extension. Its main feature however is the ability to save requested pages and it also includes a javascript "class" for viewing the saved data.

  Sources   Download

log curl logging history save