1. Go to this page and download the library: Download arch/multicurl library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arch / multicurl example snippets
use Arch\MultiCurl\MultiCurl;
use Arch\MultiCurl\MultiCurl;
$baseUrl = 'https://maps.googleapis.com/maps/api/geocode/json?';
$key = '&key=Google_Map_Keys';
$urls = array(
$baseUrl . 'latlng=3.114536,101.659844'.$key,
$baseUrl . 'latlng=3.084217,101.595965'.$key,
$baseUrl . 'latlng=3.064248,101.437435'.$key,
$baseUrl . 'latlng=3.114536,101.659844'.$key
);
$perRequest = 3; // 3 endpoints per request
$curlMulti = new MultiCurl( $urls, $perRequest );
$curlMulti->execute( function ( $data ) { // execute curl with callback for each request
echo count($data);
});
// As example, we have 3 batch requests
$curlMulti = new MultiCurl( $urls, $perRequest );
$curlMulti->execute( function ( $data ) { // execute curl with callback for each request, will run 3 times
echo count($data);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.