후 코드 GET 요청을한다 일 :.HttpURLConnection의도 (참)하려면 setDoOutput, setRequestMethod ("POST")의 setRequestProperty ("콘텐츠 여기서
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를 사용하고 있습니다 서버와는 $_GET
변수가 아닌 2.3.7 (장치) 테스트에서 $_POST
변수
를 통해 쿼리의 '이름 = 값'PARAMS에 액세스 할 수 있어요. 내가 놓친 게 무엇
?
조금 의심스러운 것 같습니다. Surl + "?" + 쿼리. 요청을 받고 있음을 어떻게 확인합니까? – tjg184
@ tjg184 저는 서버에서 PHP를 사용하고 있으며 '$ _POST' 변수가 아닌'$ _GET' 변수를 통해 쿼리의 'name = value'매개 변수에 액세스 할 수 있습니다. – ThinkingMonkey