PHP Classes

PHP cURL Multiple Requests: Send several HTTP requests to the different URLs

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 282 This week: 1All time: 7,585 This week: 571Up
Version License PHP version Categories
sdata 1.0.0MIT/X Consortium ...5HTTP, PHP 5
Description 

Author

This class can send several HTTP requests to the different URLs.

It can take an array with a list of URLs and sends HTTP GET requests to those addresses at the same, so it can collect all the responses of the respective Web servers when they return all the responses.

The class can also send send HTTP POST requests to different URLs along with additional HTTP POST parameter values.

It can as well send requests to remote Web servers using a list of distinct Web proxies.

Innovation Award
PHP Programming Innovation award nominee
September 2019
Number 3


Prize: 1GB Cloud Hosting Server - free for 1 year
Curl is a popular PHP extension that can send HTTP requests to many servers at the same time and collect all the responses after all servers handled the HTTP requests.

This class implements a solution that not only takes advantage of sending multiple HTTP requests to remote servers, but also can use a pool of proxy servers to access the remote servers, hopefully to avoid remote server throttling when that server slows down handling many requests being sent at once from the same origin IP address.

Manuel Lemos
Picture of Scoot Kemery
  Performance   Level  
Name: Scoot Kemery <contact>
Classes: 1 package by
Country: Indonesia Indonesia
Age: ???
All time rank: 388065 in Indonesia Indonesia
Week rank: 420 Up7 in Indonesia Indonesia Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
require_once("sdata-modules.php");
/**
 * @Author: Eka Syahwan
 * @Date: 2017-12-11 17:01:26
 * @Last Modified by: Nokia 1337
 * @Last Modified time: 2019-05-29 22:02:20
 */
$url = array();
for (
$i=0; $i <12; $i++) {
   
$url[] = array(
       
'url' => 'http://ip-api.com/json?id='.$i,
       
'note' => 'optional',
    );
}
$result = $sdata->sdata($url);
print_r($result);


Details

Requirements PHP 7 PHP CURL How to use GET DATA $url = array(); for ($i=0; $i <12; $i++) { $url[] = array( 'url' => 'http://exapme.com', 'note' => 'optional', ); } $result = $sdata->sdata($url); print_r($result); POST DATA $url = array(); for ($i=0; $i <12; $i++) { $custom[] = array( 'header' => array( "accept: application/json", "content-type: application/json", ), 'post' => '{"emailAddress":"example@gmail.com"}' ); $url[] = array( 'url' => 'http://example.com/post', 'note' => 'optional', ); } $result = $sdata->sdata($url , $custom); print_r($result); Use Proxy $url = array(); $proxy = array( 'ip' => '127.0.0.1', 'port' => '80' ); for ($i=0; $i <12; $i++) { $custom[] = array( 'header' => array( "accept: application/json", "content-type: application/json", ), 'proxy' => $proxy, 'post' => '{"emailAddress":"example@gmail.com"}' ); $url[] = array( 'url' => 'http://exapme.com', 'note' => 'optional', ); } $result = $sdata->sdata($url); print_r($result); Remove cookies files $url = array(); for ($i=0; $i <12; $i++) { $url[] = array( 'url' => 'http://exapme.com', 'note' => 'optional', ); } $result = $sdata->sdata($url); print_r($result); $sdata->session_remove($result); Set proxy with hostname $ProxyRotation['proxy'] = array( 'auth' => array( 'hostname' => 'http://proxy.xxxx.com', 'port' => '1222', 'username' => 'auto', 'password' => 'jmtP4ty8LoS2jJoAJXwKGaw5M', ), ); $sdata->setRules($ProxyRotation); Set Rotation proxy using rules $ProxyRotation['proxy'] = array( 'file' => 'proxy.txt', 'rules' => array( 'respons' => array('text' => 'city'), 'http_code' => array('text' => 0), ), ); $sdata->setRules($ProxyRotation); example : Rotation proxy using rules <?php require_once("sdata-modules.php"); /** * @Author: Eka Syahwan * @Date: 2017-12-11 17:01:26 * @Last Modified by: Nokia 1337 * @Last Modified time: 2019-08-17 01:44:33 */ $ProxyRotation['proxy'] = array( 'file' => 'proxy.txt', 'rules' => array( 'respons' => array('text' => 'city'), 'http_code' => array('text' => 0), ), ); $sdata->setRules($ProxyRotation); while (TRUE) { $url[] = array( 'url' => 'http://ip-api.com/json/', 'note' => $emailnya, ); $res = $sdata->sdata($url);unset($url); foreach ($res as $key => $value) { print_r($value); $json = json_decode($value[respons],true); echo $json['query']."\r\n"; } } Format proxy non auth: 127.0.0.1:1223 Format proxy with auth: 172.241.117.58:29842:bhyl:0jDYgVHn Copyright and license Code and documentation copyright the Eka Syahwan (Sdata author) Code released under the MIT License. Docs released under Creative Commons.

  Files folder image Files  
File Role Description
Accessible without login Plain text file example-get.php Example example get method
Accessible without login Plain text file info Doc. info
Plain text file sdata-modules.php Class module

 Version Control Unique User Downloads Download Rankings  
 0%
Total:282
This week:1
All time:7,585
This week:571Up