基本上我要做的是使用我创建的 PHP 页面连接到 Pastebin API。好像参数没有输入。这是我的代码:
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并且效果很好。在我的页面上,它被设置为如果参数没有全部输入,那么它会返回一条消息说这样,这就是正在发生的事情。抱歉,我问了一个已经回答的问题,但答案没有帮助。