wp_safe_remote_get()
Retrieves the raw response from a safe HTTP request using the GET method.
This function is ideal when the HTTP request is being made to an arbitrary URL. The URL, and every URL it redirects to, are validated with wp_http_validate_url() to avoid Server Side Request Forgery attacks (SSRF).
Хуков нет.
Возвращает
Массив|WP_Error
. The response or WP_Error on failure.
Использование
wp_safe_remote_get( $url, $args );
- $url(строка) (обязательный)
- URL to retrieve.
- $args(массив)
- Request arguments. See WP_Http::request() for information on accepted arguments.
По умолчанию: empty array
Заметки
- Смотрите: wp_remote_request() For more information on the response array format.
- Смотрите: WP_Http::request() For default arguments information.
- Смотрите: wp_http_validate_url() For more information about how the URL is validated.
Список изменений
С версии 3.6.0 | Введена. |
Код wp_safe_remote_get() wp safe remote get WP 6.6.2
function wp_safe_remote_get( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->get( $url, $args ); }