Wordpress 闭包编译器RESTFul API输出\u信息参数

Wordpress 闭包编译器RESTFul API输出\u信息参数,wordpress,google-closure-compiler,Wordpress,Google Closure Compiler,我在WordPress中使用Google闭包编译器RESTFul API。 请求是使用wp\u remote\u post()创建的,到目前为止一切正常 我想知道的是如何让API不仅返回编译后的代码,还返回警告、错误和统计信息 在正文参数中提供'output\u info'=>数组('compiled\u code','warnings','errors','statistics'),似乎不起作用,API返回错误。有什么想法吗 多谢各位 只是环顾四周,发现闭包编译器多次接受output\u in

我在WordPress中使用Google闭包编译器RESTFul API。 请求是使用
wp\u remote\u post()
创建的,到目前为止一切正常

我想知道的是如何让API不仅返回编译后的代码,还返回警告、错误和统计信息

正文
参数中提供
'output\u info'=>数组('compiled\u code','warnings','errors','statistics')
,似乎不起作用,API返回错误。有什么想法吗


多谢各位

只是环顾四周,发现闭包编译器多次接受
output\u info
参数。如果不做一些修改,这在WP_HttpAPI中是不可能实现的

因此,我查看了
WP_Http
的源代码,并做了以下操作,现在它开始工作了:)

// Default request data
$request_data = array(
    'output_info' => array( 'compiled_code', 'warnings', 'errors', 'statistics' ), 
    'output_format' => 'json'
);
$request_data = array_merge( $request_data, $args, compact( 'js_code' ) );

// Process the request body manually to make same named parameters possible
$body = http_build_query( $request_data, null, '&' );
$body = preg_replace( '/output_info%5B\d+%5D=/', 'output_info=', $body );

// Initiate request
$response = wp_remote_post( CLOSURE_COMPILER_URL, array(
    'sslverify' => false, 
    'timeout' => 10, 
    'headers' => array(
        'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' )
    ), 
    'body' => $body
));