PHP code example of elminson / multiproccessingcurlrequests

1. Go to this page and download the library: Download elminson/multiproccessingcurlrequests 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/ */

    

elminson / multiproccessingcurlrequests example snippets



namespace Elminson\MultiProccessingCurlRequests;

ceholder.typicode.com/todos/1'],
          ['url' => 'https://jsonplaceholder.typicode.com/users']
        ];
        $call = new MultiProccessingCurlRequests();
        $call->setIsJson(true);
        $r = $call->multiRequest($data);
        var_dump($r);



namespace Elminson\MultiProccessingCurlRequests;

> "555-555-5555");
        $data = [
          ['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'payload' => json_encode($payloadArray)],
          ['url' => 'https://jsonplaceholder.typicode.com/users', 'payload' => json_encode($payloadArray)]
        ];
        $call = new MultiProccessingCurlRequests();
        $call->setIsJson(true);
        $r = $call->multiRequest($data);
        var_dump($r);




namespace Elminson\MultiProccessingCurlRequests;

=> "555-555-5555");
		$data = [
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'post' => $payloadArray],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'post' => $payloadArray]
		];
		$call = new MultiProccessingCurlRequests();
		$call->setIsJson(true);
		$r = $call->multiRequest($data);
		var_dump($r);



namespace Elminson\MultiProccessingCurlRequests;

=> "555-555-5555");
        $headersMulticall = [
            'Content-Type: application/json',
            'Authorization: Basic username:password' // some basic auth need to be base64 encoded
        ];
		$data = [
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'post' => $payloadArray],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'post' => $payloadArray]
		];
		$call = new MultiProccessingCurlRequests();
		$call->setHeaders($headersMulticall);
		$call->setIsJson(true);
		$call->setIsPost(true);
		$r = $call->multiRequest($data);
		var_dump($r);





namespace Elminson\MultiProccessingCurlRequests;

=> "555-555-5555");
        $headersMulticall = [
            'Content-Type: application/json',
            'Authorization: Basic username:password' // some basic auth need to be base64 encoded
        ];
		$data = [
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'payload' => json_encode($payloadArray)],
			['url' => 'https://jsonplaceholder.typicode.com/todos/1', 'post' => $payloadArray],
			['url' => 'https://jsonplaceholder.typicode.com/users', 'post' => $payloadArray]
		];
		$call = new MultiProccessingCurlRequests();
		$call->setHeaders($headersMulticall);
		$call->setIsJson(true);
		$call->setIsPut(true);
		$r = $call->multiRequest($data);
		var_dump($r);