コマンドラインで動作するこのcurlコマンドをphpコードに変換できる人はいますか?
$ curl -u username@gmail.com -X POST -d "" https://build.phonegap.com/token
私はこのコードを試しましたが、うまくいきませんでした:
$target_url = "https://USERNAME@gmail.com:PASSWORD@build.phonegap.com/token"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
上記のコードを実行すると、次のエラーが発生します。
301 Moved
The document has moved here(link to gmail.com).
しかし、コマンドラインでコマンドを使用すると、正常に動作します。どこが間違っていますか?
また、その「-X」の意味と、それをphpコードに変換する方法を教えてください。
ありがとう