私はPhoneGapBuildAPIに取り組んでおり、ファイルをアップロードしてそのapkを作成しています。こちらで確認できますhttps://build.phonegap.com/docs/write_api
phpを使用してcurlを実装する際に問題が発生しています。コマンドラインの次のcurlステートメントは正常に機能しています。
$ curl -F file = @ / Users / alunny / index.html -u andrew.lunny@nitobi.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
phpを使用してこのコードを書き込もうとすると、エラーが発生します。私は次のコードを書きました。
$username = "email";
$password = "password";
$target_url = "https://build.phonegap.com/api/v1/apps";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
$post = array(
"file"=>"@www.zip",
"data"=>json_encode(array("title"=>"My Test App","package"=>"com.alunny.apiv1","version"=>"0.1.0","create_method"=>"file"))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($ch);
curl_close ($ch);
このコードを実行すると、「create_methodが指定されていません:file、remote_repo、またはhosted_repo」というエラーが発生します。
この問題の解決を手伝ってください。
ありがとうございました