WPSEO_MyYoast_Api_Request::do_request
Performs the request using WordPress internals.
Метод класса: WPSEO_MyYoast_Api_Request{}
Хуков нет.
Возвращает
Строку. The retrieved body.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->do_request( $url, $request_arguments );
- $url(строка) (обязательный)
- The request URL.
- $request_arguments(массив) (обязательный)
- The request arguments.
Код WPSEO_MyYoast_Api_Request::do_request() WPSEO MyYoast Api Request::do request Yoast 27.4
protected function do_request( $url, $request_arguments ) {
$request_arguments = $this->enrich_request_arguments( $request_arguments );
$response = wp_remote_request( $url, $request_arguments );
if ( is_wp_error( $response ) ) {
throw new WPSEO_MyYoast_Bad_Request_Exception( $response->get_error_message() );
}
$response_code = wp_remote_retrieve_response_code( $response );
$response_message = wp_remote_retrieve_response_message( $response );
// Do nothing, response code is okay.
if ( $response_code === 200 ) {
return wp_remote_retrieve_body( $response );
}
throw new WPSEO_MyYoast_Bad_Request_Exception( esc_html( $response_message ), (int) $response_code );
}