This method initiates a request and sends it via a transport before parsing. The $options parameter takes an associative array with the following options: <ul> <li>timeout: How long should we wait for a response? Note: for cURL, a minimum of 1 second applies, as DNS resolution operates at second-resolution only.(float, seconds with a millisecond precision, default: 10, example: 0.01)</li> <li>connect_timeout: How long should we wait while trying to connect? (float, seconds with a millisecond precision, default: 10, example: 0.01)</li> <li>useragent: Useragent to send to the server (string, default: php-requests/$version)</li> <li>follow_redirects: Should we follow 3xx redirects? (boolean, default: true)</li> <li>redirects: How many times should we redirect before erroring? (integer, default: 10)</li> <li>blocking: Should we block processing on this request? (boolean, default: true)</li> <li>filename: File to stream the body to instead.(string|boolean, default: false)</li> <li>auth: Authentication handler or array of user/password details to use for Basic authentication (\WpOrg\Requests\Auth|array|boolean, default: false)</li> <li>proxy: Proxy details to use for proxy by-passing and authentication (\WpOrg\Requests\Proxy|array|string|boolean, default: false)</li> <li>max_bytes: Limit for the response body size.(integer|boolean, default: false)</li> <li>idn: Enable IDN parsing (boolean, default: true)</li> <li>transport: Custom transport. Either a class name, or a transport object. Defaults to the first working transport from \WpOrg\Requests\Requests::getTransport() (string|\WpOrg\Requests\Transport, default: \WpOrg\Requests\Requests::getTransport())</li> <li>hooks: Hooks handler.(\WpOrg\Requests\HookManager, default: new WpOrg\Requests\Hooks())</li> <li>verify: Should we verify SSL certificates? Allows passing in a custom certificate file as a string. (Using true uses the system-wide root certificate store instead, but this may have different behaviour across transports.) (string|boolean, default: certificates/cacert.pem)</li> <li>verifyname: Should we verify the common name in the SSL certificate? (boolean, default: true)</li> <li>data_format: How should we send the $data parameter? (string, one of 'query' or 'body', default: 'query' for HEAD/GET/DELETE, 'body' for POST/PUT/OPTIONS/PATCH)</li> </ul>
Parameters
$urlstring|WpOrg\Requests\Stringable
URL to request
$headersarrayoptional
Extra headers to send with the requestDefault: []
$dataarray|nulloptional
Data to send either as a query string for GET/HEAD requests, or in the body for POST requestsDefault: []
$typestringoptional
HTTP request type (use Requests constants)Default: self::GET
$optionsarrayoptional
Options for the request (see description for more information)Default: []
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/Requests/src/Requests.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.