$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
$response = Run::Async($promise);
# 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"
];
$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
$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
$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');
$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
To install the source code:
$ git clone https://github.com/Mateodioev/req-async.git
$ composer require mateodioev/async-curl-requests:dev-master
And include it in your scripts:
require './vendor/autoload.php';
use Async\Req;
use Async\Run;