这是在命令行中工作的 curl 代码:
$ curl -F file=@/path/to/index.html -u lslkdfmkls@gmail.com -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"}
有什么解决办法?
谢谢