Zebra_cURL::queue PHP Method

queue() public method

Until {@link start} method is called, all calls to {@link delete}, {@link download}, {@link ftp_download}, {@link get}, {@link header}, {@link post} and {@link put} methods will queue up rather than being executed right away. Once the {@link start} method is called, all queued requests will be processed while values of {@link threads} and {@link pause_interval} properties will still apply. 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('
');
            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();
queue requests - useful for grouping different types of requests
in this example, when the "start" method is called, we'll execute
the "get" and the "post" requests simultaneously as if it was a
single request
$curl->queue();
do a POST and execute the "mycallback" function for each
request, as soon as it finishes
$curl->post(array(
    'http://www.somewebsite.com'  =>  array(
        'data_1'  =>  'value 1',
        'data_2'  =>  'value 2',
    ),
), 'mycallback');
let's fetch the RSS feeds of some popular websites
execute the "mycallback" function for each request, as soon as it finishes
$curl->get(array(
    'http://feeds.feedburner.com/alistapart/main',
    'http://feeds.feedburner.com/TechCrunch',
    'http://feeds.mashable.com/mashable',
), 'mycallback')
execute queued requests
$curl->start();
        
Since: 1.3.0 @return void
public queue ( ) : void
return void
    public function queue()
    {
        // set a flag indicating the library to queue requests rather than executing them right away
        $this->_queue = true;
    }