Last active
February 22, 2021 18:42
-
-
Save timersys/4480bccf64a1147abb3d to your computer and use it in GitHub Desktop.
wp_remote_get debug script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Wp Remote Test | |
* Plugin URI: | |
* Version: 0.1 | |
* Description: Debug wp_remote_get and wp_remote_post | |
* Author: Damian Logghe | |
* Author URI: http://wp.timersys.com | |
*/ | |
if( isset($_GET['wp_remote_test'])) { | |
add_filter( 'https_ssl_verify', '__return_false' ); | |
add_action( 'init', 'debug_filters',1); | |
add_action( 'http_api_debug','debug_http',10,5); | |
add_action( 'http_api_curl', 'display_api_curl', 10, 3 ); | |
add_filter( 'http_request_args', 'display_http_request_args', 10, 2 ); | |
add_filter( 'http_api_transports', 'display_http_api_transport_args', 10, 3 ); | |
$response = wp_remote_request( 'https://wp.timersys.com/', array( 'timeout' => 15, 'sslverify' => false ) ); | |
echo '<h2>RESPONSE</h2>'; | |
echo '<pre>'; | |
var_dump($response); | |
echo '</pre>'; | |
die(); | |
} | |
function debug_http( $response, $response_test, $class, $args, $url ){ | |
echo '<h2>HTTP API DEBUG</h2>'; | |
echo '<h3>Response</h3>'; | |
echo '<pre>'; | |
var_dump($response); | |
echo '</pre>'; | |
echo '<h3>Transport used</h3>'; | |
echo '<pre>'; | |
var_dump($class); | |
echo '</pre>'; | |
echo '<h3>http arguments</h3>'; | |
echo '<pre>'; | |
var_dump($args); | |
echo '</pre>'; | |
return $response; | |
} | |
function display_api_curl( &$handle, $args, $url ) { | |
echo '<h2>API CURL</h2>'; | |
echo '<h3>handle</h3>'; | |
echo '<pre>'; | |
var_dump($handle); | |
echo '</pre>'; | |
echo '<h3>Args</h3>'; | |
echo '<pre>'; | |
var_dump($args); | |
echo '</pre>'; | |
curl_setopt($handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); | |
curl_setopt($handle, CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); | |
curl_getinfo($handle); | |
return $handle; | |
} | |
// error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure | |
// error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure | |
function display_http_request_args( $args, $url ) { | |
echo '<pre>display_http_request_args args | |
' . print_r( $args, true ) . '</pre>'; | |
return $args; | |
} | |
function display_http_api_transport_args( $transport, $args, $url ) { | |
echo '<pre>display_http_api_transport_args transport ' . print_r( $transport, 1 ) . ' | |
' . print_r( $args, true ) . '</pre>'; | |
return $transport; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment