您可以使用以下代码转储HTTP Api响应,这将帮助您找出错误原因。
function dump_http_api_response($response, $type="", $transport=null ) {
if ( $type == "response" )
var_dump ( $response );
}
add_action(\'http_api_debug\', \'dump_http_api_response\', 1, 3);
输出示例:
object(WP_Error)#15 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(41) "Couldn\'t resolve host \'api.wordpress.org\'" } } ["error_data"]=> array(0) { } }