Skip to content

Instantly share code, notes, and snippets.

@govaniso
Created July 10, 2012 16:57
Show Gist options
  • Save govaniso/3084688 to your computer and use it in GitHub Desktop.
Save govaniso/3084688 to your computer and use it in GitHub Desktop.
<?php
require_once('parallelcurl.php');
$url1 = 'http://www.example.com/');
$url2 = 'http://www.example.com/');
$url3 = 'http://www.example.com/');
// This function gets called back for each request that completes
function on_request_done($content, $url, $ch, $search) {
...
}
$max_requests = 10;
$curl_options = array(
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => FALSE
);
$parallel_curl = new ParallelCurl($max_requests, $curl_options);
// Start 3 parallel requests. All three will be started simultaneously.
$parallel_curl->startRequest($url1, 'on_request_done');
$parallel_curl->startRequest($url2, 'on_request_done');
$parallel_curl->startRequest($url3, 'on_request_done');
$parallel_curl->finishAllRequests();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment