public function proxy($proxy, $port = 80, $username = '', $password = '') {

        // if not disabled
        if ($proxy) {

            // set the required options
            $this->option(array(
                CURLOPT_HTTPPROXYTUNNEL     =>  1,
                CURLOPT_PROXY               =>  $proxy,
                CURLOPT_PROXYPORT           =>  $port,
            ));

            // if a username is also specified
            if ($username != '')

                // set authentication values
                $this->option(CURLOPT_PROXYUSERPWD, $username . ':' . $password);

        // if disabled
        } else

            // unset proxy-related options
            $this->option(array(
                CURLOPT_HTTPPROXYTUNNEL     =>  null,
                CURLOPT_PROXY               =>  null,
                CURLOPT_PROXYPORT           =>  null,
            ));

    }
public function proxy($proxy, $port = 80, $username = '', $password = '') {

        // if not disabled
        if ($proxy) {

            // set the required options
            $this->option(array(
                CURLOPT_HTTPPROXYTUNNEL     =>  1,
                CURLOPT_PROXY               =>  $proxy,
                CURLOPT_PROXYPORT           =>  $port,
            ));

            // if a username is also specified
            if ($username != '')

                // set authentication values
                $this->option(CURLOPT_PROXYUSERPWD, $username . ':' . $password);

        // if disabled
        } else

            // unset proxy-related options
            $this->option(array(
                CURLOPT_HTTPPROXYTUNNEL     =>  null,
                CURLOPT_PROXY               =>  null,
                CURLOPT_PROXYPORT           =>  null,
            ));

    }
public function proxy ( $ proxy , $ port = 80 , $ username = '' , $ password = '' ) { // if not disabled if ( $ proxy ) { // set the required options $ this -> option ( array ( CURLOPT_HTTPPROXYTUNNEL => 1 , CURLOPT_PROXY => $ proxy , CURLOPT_PROXYPORT => $ port , ) ) ; // if a username is also specified if ( $ username != '' ) // set authentication values $ this -> option ( CURLOPT_PROXYUSERPWD , $ username . ':' . $ password ) ; // if disabled } else // unset proxy-related options $ this -> option ( array ( CURLOPT_HTTPPROXYTUNNEL => null , CURLOPT_PROXY => null , CURLOPT_PROXYPORT => null , ) ) ; }
Instruct the library to tunnel all requests through a proxy server.

<code>
// the callback function to be executed for each and every
// request, as soon as a request finishes
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 class
$curl = new Zebra_cURL();

// connect to a proxy server
// (that's a random one i got from http://www.hidemyass.com/proxy-list/)
$curl->proxy('187.63.32.250', '3128');

// fetch a page
$curl->get('http://www.somewebsite.com/', 'mycallback');
</code>

@param  string      $proxy      The HTTP proxy to tunnel requests through.

Can be an URL or an IP address.

<i>This option can also be set using the {@link option} method and setting </i>
<b>CURLOPT_PROXY</b> <i> option to the desired value</i>.

Setting this argument to FALSE will "unset" all the proxy-related options.

@param  string      $port       (Optional) The port number of the proxy to connect to.

Default is 80.

<i>This option can also be set using the {@link option} method and setting </i>
<b>CURLOPT_PROXYPORT</b> <i> option to the desired value</i>.

@param  string      $username   (Optional) The username to be used for the connection to the proxy (if required
by the proxy)

Default is "" (an empty string)

<i>The username and the password can also be set using the {@link option} method
and setting </i> <b>CURLOPT_PROXYUSERPWD</b> <i> option to the desired value
formatted like </i> <b>[username]:[password]</b>.     .

@param  string      $password   (Optional) The password to be used for the connection to the proxy (if required
by the proxy)

Default is "" (an empty string)

<i>The username and the password can also be set using the {@link option} method
and setting </i> <b>CURLOPT_PROXYUSERPWD</b> <i> option to the desired value
formatted like </i> <b>[username]:[password]</b>.     .

@return void
Instruct the library to tunnel all requests through a proxy server .