Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function slug_make_request( $api ){
- $r = wp_remote_request( $api );
- if( is_wp_error( $r ) ){
- throw new Exception( $r->get_error_message() );
- }
- return wp_remote_retrieve_body( $r );
- }
- try {
- $url = 'http://somurl.com/wp-json';
- $response = slug_make_request( $url );
- } catch (Exception $e) {
- if( class_exists( 'WP_Papertrail_API' ) ){
- WP_Papertrail_API::log( [
- 'error' => $e->getMessage(),
- 'url' => $url
- ], 'api_request_failed' );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement