public function http_authentication($username = '', $password = '', $type = CURLAUTH_ANY) {

        // set the required options
		$this->option(array(
            CURLOPT_HTTPAUTH    =>  ($username == '' && $password == '' ? null : $type),
            CURLOPT_USERPWD     =>  ($username == '' && $password == '' ? null : ($username . ':' . $password)),
        ));

    }
public function http_authentication($username = '', $password = '', $type = CURLAUTH_ANY) {

        // set the required options
		$this->option(array(
            CURLOPT_HTTPAUTH    =>  ($username == '' && $password == '' ? null : $type),
            CURLOPT_USERPWD     =>  ($username == '' && $password == '' ? null : ($username . ':' . $password)),
        ));

    }
public function http_authentication ( $ username = '' , $ password = '' , $ type = CURLAUTH_ANY ) { // set the required options $ this -> option ( array ( CURLOPT_HTTPAUTH => ( $ username == '' && $ password == '' ? null : $ type ) , CURLOPT_USERPWD => ( $ username == '' && $ password == '' ? null : ( $ username . ':' . $ password ) ) , ) ) ; }
Use this method to make requests to pages that require prior HTTP authentication.

<code>
// the callback function to be executed for each and every
// request, as soon as a request finishes
// the callback function receives as argument an object with 4 properties
// (info, header, body and response)
function mycallback($result) {

// everything went well at cURL level
if ($result->response[1] == CURLE_OK) {

// if server responded with code 200 (meaning that everything went well)
// see http://httpstatus.es/ for a list of possible response codes
if ($result->info['http_code'] == 200) {

// see all the returned data
print_r('<pre>');
print_r($result);

// show the server's response code
} else die('Server responded with code ' . $result->info['http_code']);

// something went wrong
// ($result still contains all data that could be gathered)
} else die('cURL responded with: ' . $result->response[0]);

}

// include the Zebra_cURL library
require 'path/to/Zebra_cURL';

// instantiate the Zebra_cURL object
$curl = new Zebra_cURL();

// prepare user name and password
$curl->http_authentication('username', 'password');

// get content from a page that requires prior HTTP authentication
$curl->get('http://www.some-page-requiring-prior-http-authentication.com', 'mycallback');
</code>

If you have to unset previously set values use
<code>
$curl->http_authentication();
</code>

@param  string      $username       User name to be used for authentication.

@param  string      $password       Password to be used for authentication.

@param  string      $type           (Optional) The HTTP authentication method(s) to use. The options are:

-   <b>CURLAUTH_BASIC</b>
-   <b>CURLAUTH_DIGEST</b>
-   <b>CURLAUTH_GSSNEGOTIATE</b>
-   <b>CURLAUTH_NTLM</b>
-   <b>CURLAUTH_ANY</b>
-   CU<b>RLAUTH_ANYSAFE</b>

The bitwise | (or) operator can be used to combine more than one method. If
this is done, cURL will poll the server to see what methods it supports and
pick the best one.

<b>CURLAUTH_ANY</b> is an alias for <b>CURLAUTH_BASIC</b> | <b>CURLAUTH_DIGEST</b> |
<b>CURLAUTH_GSSNEGOTIATE</b> | <b>CURLAUTH_NTLM</b>.

<b>CURLAUTH_ANYSAFE</b> is an alias for <b>CURLAUTH_DIGEST</b> | <b>CURLAUTH_GSSNEGOTIATE</b> |
<b>CURLAUTH_NTLM</b>.

Default is <b>CURLAUTH_ANY</b>.

@return void
Use this method to make requests to pages that require prior HTTP authentication .