WP_CLI
WpOrgApi::get_request
Execute a remote GET request.
Метод класса: WpOrgApi{}
Хуков нет.
Возвращает
Строку. Response body.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_request( $url, $headers, $options );
- $url(строка) (обязательный)
- URL to execute the GET request on.
- $headers(массив)
- Associative array of headers.
По умолчанию:[] - $options(массив)
- Associative array of options.
По умолчанию:[]
Код WpOrgApi::get_request() WpOrgApi::get request WP-CLI 2.13.0-alpha
private function get_request( $url, $headers = [], $options = [] ) {
$options = array_merge(
$this->options,
[
'halt_on_error' => false,
],
$options
);
$response = Utils\http_request( 'GET', $url, null, $headers, $options );
if (
! $response->success
|| 200 > (int) $response->status_code
|| 300 <= $response->status_code
) {
throw new RuntimeException(
"Couldn't fetch response from {$url} (HTTP code {$response->status_code})."
);
}
return trim( $response->body );
}