2013-07-03 4 views
0

Google's Closure Compiler과 협력하려고하는데, 불행히도 cURL의 게시판에 문제가 발생했습니다. 여기에 배열을 지정하면 작동하는 방식대로 작동하지 않는 것 같습니다. 이 같은 postfields에 배열을 전달하여cURL 게시판 문제

는 :

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); 

나는 내가 output_info 매개 변수를 설정하지 않은 나타내는 구글에서 오류 (13)을 얻는다. 그러나 postfield를 리터럴 문자열로 전달하면 다음과 같이 모든 것이 올바르게 작동하고 응답에서 축소 된 JS 코드가 생성됩니다.

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); 

여기서 내가 뭘 잘못하고 있니?

+0

'CURLOPT_POST'을 (를) 설정하고 PHP 5.4 이상을 실행한다고 가정합니다. –

+0

@JasonMcCreary 네, 모두 맞습니다. – RemiDG

+0

[Google 클로저 컴파일러 및 여러 부분/양식 데이터가 작동하지 않음] (http://stackoverflow.com/questions/8975758/google-closure-compiler-and-multipart-form-data-not-working)의 가능한 복제본입니다. –

답변

0

저는 이것이 중복 된 질문이라고 생각합니다. Google Closure Compiler and multipart/form-data not working을 참조하십시오.

짧은 이야기 - 당신이 curl_setopt에 배열을 전달하면 Content-Type 헤더가 Google의 API에서 지원되지 않는 multipart/form-data로 변경됩니다.

+1

그 것처럼 보였습니다. 왜 문제를 찾을 수 없었는지 설명 할 수 있습니다. 꽤 절름발이. – RemiDG

+0

이 경우이 질문에 표시를하여 복제본으로 닫아야합니다. –