Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_remote_request [ WordPress Function ]

wp_remote_request ( $url, $args = array() )
Parameters:
  • (string) $url Site URL to retrieve.
  • (array) $args Optional. Override the defaults.
Returns:
  • (WP_Error|array) The response or WP_Error on failure.
Defined at:



Retrieve the raw response from the HTTP request.

The array structure is a little complex.

$res = array( 'headers' => array(), 'response' => array('code' => int, 'message' => string) );

All of the headers in $res['headers'] are with the name as the key and the value as the value. So to get the User-Agent, you would do the following.

$user_agent = $res['headers']['user-agent'];

The body is the raw response content and can be retrieved from $res['body'].

This function is called first to make the request and there are other API functions to abstract out the above convoluted setup.

Source


<?php
function wp_remote_request($url$args = array()) {
    
$objFetchSite _wp_http_get_object();
    return 
$objFetchSite->request($url$args);
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics