WpOrg\Requests
Session::__construct()
Create a new session
Method of the class: Session{}
No Hooks.
Return
null
. Nothing (null).
Usage
$Session = new Session(); $Session->__construct( $url, $headers, $data, $options );
- $url(string|Stringable|null)
- Base URL for requests
Default: null - $headers(array)
- Default headers for requests
Default: [] - $data(array)
- Default data for requests
Default: [] - $options(array)
- Default options for requests
Default: []
Session::__construct() Session:: construct code WP 6.6.2
public function __construct($url = null, $headers = [], $data = [], $options = []) { if ($url !== null && InputValidator::is_string_or_stringable($url) === false) { throw InvalidArgument::create(1, '$url', 'string|Stringable|null', gettype($url)); } if (is_array($headers) === false) { throw InvalidArgument::create(2, '$headers', 'array', gettype($headers)); } if (is_array($data) === false) { throw InvalidArgument::create(3, '$data', 'array', gettype($data)); } if (is_array($options) === false) { throw InvalidArgument::create(4, '$options', 'array', gettype($options)); } $this->url = $url; $this->headers = $headers; $this->data = $data; $this->options = $options; if (empty($this->options['cookies'])) { $this->options['cookies'] = new Jar(); } }