Requests::request_multiple( array $requests, array $options = array() ): array

In this article

Send multiple HTTP requests simultaneously

Description

The $requests parameter takes an associative or indexed array of request fields. The key of each request can be used to match up the request with the returned data, or with the request passed into your multiple.request.complete callback.

The request fields value is an associative array with the following keys:

  • url: Request URL Same as the $url parameter to Requests::request (string, required)
  • headers: Associative array of header fields. Same as the $headers parameter to Requests::request (array, default: array())
  • data: Associative array of data fields or a string. Same as the $data parameter to Requests::request (array|string, default: array())
  • type: HTTP request type (use Requests constants). Same as the $type parameter to Requests::request (string, default: Requests::GET)
  • cookies: Associative array of cookie name to value, or cookie jar.
    (array|Requests_Cookie_Jar)

If the $options parameter is specified, individual requests will inherit options from it. This can be used to use a single hooking system, or set all the types to Requests::POST, for example.

In addition, the $options parameter takes the following global options:

  • complete: A callback for when a request is complete. Takes two parameters, a Requests_Response/Requests_Exception reference, and the ID from the request array (Note: this can also be overridden on a per-request basis, although that’s a little silly) (callback)

Parameters

$requestsarrayrequired
Requests data (see description for more information)
$optionsarrayoptional
Global and default options (see Requests::request)

Default:array()

Return

array Responses (either Requests_Response or a Requests_Exception object)

Source

User Contributed Notes

You must log in before being able to contribute a note or feedback.