PHP Classes

PHP Asynchronous HTTP Request: Queue and send multiple asynchronous HTTP requests

Recommend this page to a friend!

  Author Author  
Picture of Mateo
Name: Mateo <contact>
Classes: 13 packages by
Country: Peru Peru
Age: ???
All time rank: 31979 in Peru Peru
Week rank: 65 Up1 in Peru Peru Up
Innovation award
Innovation award
Nominee: 4x


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This package can queue and send multiple asynchronous HTTP requests.

It can store in an array the parameters of HTTP requests to be sent to remote Web servers.

The parameters define details of the HTTP requests like the URL, HTTP method, the request headers, file to store cookies, etc..

The package can send the HTTP requests in parallel using the Curl extension and returns the results when all requests are finished.


Details

Async requests

Create new request

$req = new Req();
$promise = array();
$promise[] = $req::Get('https://httpbin.org/get'); // GET method
$promise[] = $req::Post('https://httpbin.org/post'); // POST method
$promise[] = $req::Put('https://httpbin.org/put'); // CUSTOM method

Run all request

$response = Run::Async($promise);

Proxy sintax

# PROXY (http/s, socks4, socks5)
$server = [
    "METHOD" => "TUNNEL",
    "SERVER" => "ip:port"
];

# Windscribe
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" = "socks5h://socks-us.windscribe.com:1080",
    "AUTH" => "w07l3gbt-r6vxdfpb:ucxqefrada3h"
];

# Webshare
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" = "p.webshare.io:80",
    "AUTH" => "user-rotate:pass"
];


# APIFY valid syntax example
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" = "http://proxy.apify.com:8000",
    "AUTH" => "auto:pasword"
];

# IPVANISH valid syntax example
$server = [
    "METHOD" => "CUSTOM",
    "SERVER" => "akl-c12.ipvanish.com:1080",
    "AUTH"   => "my_zone_customer_id:my_zone_customer_password"
];

Get sintax

$headers = ['Origin: https://google.com/', 'MSG: testing'];
$server = ["METHOD" => "TUNNEL", "SERVER" => "ip:port"];

$req = new Req();
$promise = array();

$promise[] = $req::Get('https://httpbin.org/get');
$promise[] = $req::Get('https://httpbin.org/get', $headers); // Using headers
$promise[] = $req::Get('https://httpbin.org/cookies/set?name=John&age=25', $headers, null, 'file_example_cookie_file'); // Using headers and cookies
$promise[] = $req::Get('https://httpbin.org/get', null, $server); // Using only proxy

$response = Run::Async($promise); // Run all resquests

Post sintax

$headers = ['Origin: https://google.com/', 'MSG: testing'];
$server = ["METHOD" => "TUNNEL", "SERVER" => "ip:port"];
$post = ['name' => 'Jhon', 'age' => 25];

$req = new Req();
$promise = array();

$promise[] = $req::Post('https://httpbin.org/post'); // Simple resquest
$promise[] = $req::Post('https://httpbin.org/post', http_build_query($post)); // Post data
$promise[] = $req::Post('https://httpbin.org/post', $post); // Post (in json)
$promise[] = $req::Post('https://httpbin.org/post', $post, $headers); // Post (in json) and headers
$promise[] = $req::Post('https://httpbin.org/cookies/set?name=John&age=25', null, $headers, null, 'cookie_example'); // Using headers and cookies

Custom methods

$req = new Req();
$promise = array();

/
 * Format:
 * $promise[] = $req::MethodName('url', $post_data, $headers, $server, $cookie_name);
 * $response = Run::Async($promise);
*/
$promise[] = $req::Put('https://httpbin.org/put');
$promise[] = $req::Patch('https://httpbin.org/patch');
$promise[] = $req::Delete('https://httpbin.org/delete');

Run requests

$req = new Req();
$promise = array();

for ($i=0; $i < 10; $i++) {
    $promise[] = $req::Get('https://httpbin.org/get');
}

$response = Run::Async($promise); // Run all resquests
$response = Run::Async([$promise[0], $promise[1]]); // Run someone resquests
$response = Run::Async($promise, 100); // Modified ms

Installation

Install source from GitHub

To install the source code:

$ git clone https://github.com/Mateodioev/req-async.git

Install from Composer

$ composer require mateodioev/async-curl-requests:dev-master

And include it in your scripts:

require './vendor/autoload.php';
use Async\Req;
use Async\Run;

  Classes of Mateo  >  PHP Asynchronous HTTP Request  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Asynchronous HTTP Request
Base name: req-async
Description: Queue and send multiple asynchronous HTTP requests
Version: 1.0.0
PHP version: 5
License: MIT/X Consortium License
All time users: 85 users
All time rank: 9851
Week users: 0 users
Week rank: 130 Equal
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image HTTP HTTP protocol clients, headers and cookies View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes


  User ratings  
Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagesrc (6 files)
Files folder imagevendor (1 file, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file examples.php Example Example script
Accessible without login Plain text file readme.MD Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file Cookie.php Class Class source
  Plain text file Headers.php Class Class source
  Plain text file Proxy.php Class Class source
  Plain text file Req.php Class Class source
  Plain text file Run.php Class Class source
  Plain text file StringUtil.php Class Class source

  Files folder image Files  /  vendor  
File Role Description
Files folder imagecomposer (11 files)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script

  Files folder image Files  /  vendor  /  composer  
File Role Description
  Accessible without login Plain text file autoload_classmap.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_namespaces.php Aux. Auxiliary script
  Accessible without login Plain text file autoload_psr4.php Aux. Auxiliary script
  Plain text file autoload_real.php Class Class source
  Plain text file autoload_static.php Class Class source
  Plain text file ClassLoader.php Class Class source
  Accessible without login Plain text file installed.json Data Auxiliary data
  Accessible without login Plain text file installed.php Aux. Auxiliary script
  Plain text file InstalledVersions.php Class Class source
  Accessible without login Plain text file LICENSE Lic. License text
  Accessible without login Plain text file platform_check.php Aux. Auxiliary script

Install with Composer Install with Composer - Download Download all files: req-async.tar.gz req-async.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.