0
這是捲曲的代碼,在命令行工作:嫋嫋不發送POST數據,但在正常工作終端
$ curl -F [email protected]/path/to/index.html -u [email protected] -F 'data={"title":"API V1 App","package":"com.alunny.apiv1","version":"0.1.0","create_method":"file"}' https://build.phonegap.com/api/v1/apps
這是我的代碼:
$ch = curl_init();
$data = array("title"=>"sampele title","package"=>"com.fsdlfn.sdfknsdj","version"=>"0.1.0","create_method"=>"file","file"=>"@/path/myfolder/myfile.zip");
$jsdata = json_encode($data);
curl_setopt($ch, CURLOPT_URL, 'https://build.phonegap.com/api/v1/app?auth_token='.$token); //got this token already, so using that here .
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsdata);
echo curl_exec($ch);
curl命令在終端工作,但上面的curl命令用php編寫,返回錯誤:返回錯誤:
{"error":"no create_method specified: file, remote_repo, or hosted_repo"}
什麼是解決方案?
感謝
工作!謝謝 – user1434480
非常感謝您的清晰解釋! – user1434480