Requests_Session::request_multiple() WordPress Method

The Requests_Session::request_multiple() method makes it easy to send multiple HTTP requests in parallel. This can be useful when making multiple API calls, for example. To use this method, simply pass an array of request objects (created using the Requests::request() method) to Requests_Session::request_multiple(). Requests_Session::request_multiple() will then return an array of responses, in the same order as the requests were made.

Requests_Session::request_multiple( array $requests, array $options = array() ) #

Send multiple HTTP requests simultaneously


Description

Top ↑

See also


Top ↑

Parameters

$requests

(array)(Required)Requests data (see Requests::request_multiple)

$options

(array)(Optional)Global and default options (see Requests::request)

Default value: array()


Top ↑

Return

(array) Responses (either Requests_Response or a Requests_Exception object)


Top ↑

Source

File: wp-includes/Requests/Session.php

	public function request_multiple($requests, $options = array()) {
		foreach ($requests as $key => $request) {
			$requests[$key] = $this->merge_request($request, false);
		}

		$options = array_merge($this->options, $options);

		// Disallow forcing the type, as that's a per request setting
		unset($options['type']);

		return Requests::request_multiple($requests, $options);
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.