I'm trying to work with Google's Closure Compiler, unfortunately I stumbled upon a problem with cURL's postfields. It seems to be that when I specify an array here, it doesn't work the way it's supposed to work.
By passing an array to the postfields like this:
curl_setopt($this->curl, CURLOPT_POSTFIELDS, [
"output_info" => "compiled_code",
"output_format" => "text",
"compilation_level" => "SIMPLE_OPTIMIZATIONS",
"js_code" => urlencode($jsCode),
]);
$result = curl_exec($this->curl);
var_dump($result);
I get an error 13 from Google, indicating I haven't set the output_info
parameter. However, when I pass the postfields as a literal string, like the following, everything does work fine and I get the minified JS code in the response.
curl_setopt($this->curl, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($jsCode));
$result = curl_exec($this->curl);
var_dump($result);
What am I doing wrong here?