基本的に私が作成しようとしているのは、作成したPHPページでPastebin APIに接続することです。あたかもパラメータが入力されていないかのようです。私のコードは次のとおりです:JavaでのHTTP POST要求
String urlParameters = "?api_dev_key=" + main.getKey() + "&api_user_name=" + username + "&api_user_password=" + password; URL url = new URL("http://pastebinclient.tk/server/login.php" + urlParameters);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Language", "en-US");
connection.setRequestProperty("Accept", "*/*");
connection.setRequestProperty("User-Agent", "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36");
connection.setUseCaches(false);
connection.setDoOutput(true);
同じパラメータでhttp://hurl.itを使用しましたが、うまくいきました。私のページでは、パラメータがすべて入力されていない場合は、それを示すメッセージが返されるように設定されています。申し訳ありませんが、私は既に回答されている質問をしていますが、答えは役に立たなかった。
申し訳ありませんが、お試しいただきありがとうございます! – Andrewboy159
それはうまくいかなかった、私はまだなぜか分からない。それはとにかく固定されています。 Unirest-Javaを使用しました。素晴らしいです!強くお勧めします! – Andrewboy159