コードは次のとおりです。
String Surl = "http://mysite.com/somefile";
String charset = "UTF-8";
query = String.format("param1=%s¶m2=%s",
URLEncoder.encode("param1", charset),
URLEncoder.encode("param2", charset));
HttpURLConnection urlConnection = (HttpURLConnection) new URL(Surl + "?" + query).openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
urlConnection.setAllowUserInteraction(false);
urlConnection.setRequestProperty("Accept-Charset", charset);
urlConnection.setRequestProperty("User-Agent","<em>Android</em>");
urlConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded;charset=" + charset);
urlConnection.connect();
上記はまだGET
リクエストを行います。
サーバーで PHP を使用しており、2.3.7 (デバイス) でテスト済み$_GET
の変数ではなく、変数を$_POST
介してクエリの 'name=value' パラメータにアクセスできます。
何が欠けていますか?