0
我使用HttpUrlConnection來連接一個Web服務,我有一個窗體和一個按鈕。Post with HTTPUrlConnection
源代碼的部分是:
<form action="main.php4?page=markt3art=UIN=484504321483db0fc35d1e8e660b99c8&x=&y=filled=1" method="POST">
<input type="hidden" value="" name="p"></input>
<input type="hidden" value="1755219" name="buy2f8d0"></input>
<input type="hidden" value="1755219" name="buy"></input>
<input type="text" value="323" size="9" maxlength="16" name="teilkauf"></input>
<img width="1" hspace="20" height="1" src="pics/leer.gif"></img>
<input class="send" type="submit" value=" buy "></input>
</form>
我在做什麼是:(www是網站的http:// ...)
URL url = new URL(www);
HttpURLConnection conexion = (HttpURLConnection)url.openConnection();
String forSending = "1";
String charset = "UTF-8";
String stringToSend = URLEncoder.encode(forSending, charset);
conexion.setDoOutput(true);
conexion.setRequestMethod("POST");
OutputStreamWriter out = new OutputStreamWriter(
conexion.getOutputStream());
out.write("teilkauf=" + stringToSend);
out.flush();
out.close();
但它不」工作。任何幫助?謝謝。
難道我只有通過HTTP來改變WWW(網站) ://...main.php4頁= markt3art = UIN = 484504321483db0fc35d1e8e660b99c8&X =&Y =填充= 1?因爲它不起作用。 (對不起我的英語不好)。 – Kakuti
您可能需要在每次要發佈該數據時都要獲取該UIN令牌。 –