Skip to content

Instantly share code, notes, and snippets.

@afragen
Created November 21, 2015 01:06
Show Gist options
  • Save afragen/dcf32c570d6a58056e2f to your computer and use it in GitHub Desktop.
Save afragen/dcf32c570d6a58056e2f to your computer and use it in GitHub Desktop.
Debug HTTP API calls in WordPress
<?php
add_action( 'http_api_debug', 'viper_http_api_debug', 15, 5 );
function viper_http_api_debug( $response, $type, $class, $args, $url ) {
// You can change this from error_log() to var_dump() but it can break AJAX requests
var_dump( "\n<br />" . 'Request URL: ' . var_export( $url, true ) );
var_dump( "\n<br />" . 'Request Args: ' . var_export( $args, true ) );
var_dump( "\n<br />" . 'Request Response : ' . var_export( $response, true ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment