https://build.phonegap.com/docs/apiにある API を使用して phonegap アプリケーションを構築したい
トークンを返す次の curl コマンドを実行する必要があります。
$ curl -u andrew.lunny@nitobi.com -X POST "" https://build.phonegap.com/token
このcurlステートメントは、コマンドラインで機能しています。phpで使いたいです。以下のphpコードを試しましたが、うまくいきません。
$username = "USERNAME@gmail.com";
$password = "PASSWORD";
$target_url = "https://build.phonegap.com/token"
$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_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($ch);
curl_close ($ch);
echo $result;