Description
wrapper to wp_remote_get for both HEAD and json bodyThe resulting array contains the request returned from the call – so that we can look at information in the 'headers' – and the decoded JSON from the retrieved body, if set. Note: The default method, 'GET', can be overridden in the $args array. This allows us to use 'PUT' as well.
Usage
$array = oik_remote::bw_remote_geth( $url, $args );Parameters
- $url
- ( string ) required – the target URL for the GET
- $args
- ( array ) optional – additional parameters to wp_remote_get
Returns
array consisting of the result of the request and the JSON resultSource
File name: oik/libs/class-oik-remote.phpLines:
1 to 19 of 19
static function bw_remote_geth( $url, $args=null ) { $request = wp_remote_get( $url, $args ); bw_trace2( $request, "request" ); if ( is_wp_error( $request ) ) { bw_trace2( $request, "request is_wp_error" ); self::bw_retrieve_result( $request ); $result = null; } else { $json = wp_remote_retrieve_body( $request ); bw_trace2( $json ); if ( empty( $json ) ) { $result = null; } else { $result = json_decode( $json ); } } //bw_trace2( $result, "result", false ); return( array( $request, $result ) ); }View on GitHub View on Trac
Called by
Invoked by
Calls
1 to 2 of 2
