我試圖讓代碼閉包工作,但不幸的是,總是有一個錯誤拋出。如何使用Perl的LWP :: UserAgent訪問Closure JavaScript minifier?
下面的代碼:
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Response;
my $name = 'test.js';
my $agent = new LWP::UserAgent();
$agent->agent("curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18");
$res = $agent->request(POST 'http://closure-compiler.appspot.com/compile',
content_type => 'multipart/form-data',
content => [
output_info => 'compiled_code',
compilation_level => 'SIMPLE_OPTIMIZATIONS',
output_format => 'text',
js_code => [File::Spec->rel2abs($name)]
]);
if ($res->is_success) {
$minified = $res->decoded_content;
print $minified;die;
}
我收到以下錯誤:
Error(13): No output information to produce, yet compilation was requested.
下面是我用的API參考: http://code.google.com/intl/de-DE/closure/compiler/docs/api-ref.html
希望任何人知道發生了什麼事情錯在這裏。謝謝。
你爲什麼要僞造'用戶agent'? – 2010-08-14 01:05:08
如果您不反對使用更多模塊,請搜索http://search.cpan.org上的'Closure',此任務已經至少兩次製作爲模塊。 – MkV 2010-08-14 01:13:44