Create a new session
Parameters
$url
string|WpOrgRequestsStringable|nulloptional- Base URL for requests
Default:
null
$headers
arrayoptional- Default headers for requests
Default:
array()
$data
arrayoptional- Default data for requests
Default:
array()
$options
arrayoptional- Default options for requests
Default:
array()
Source
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();
}
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.