여기 httpPost() 자바 클래스, 또한 httpGet()을 숨기려면 httpPost()하는 방법?
public String getXmlFromUrl_NewRegistration(String url,
String username, String firstname, String lastname, String email,
String password) {
String json = null;
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://aleedex.biz/game/users.php?action=new");
String postParameter = "username=" + username + "&firstname="
+ firstname + "&lastname=" + lastname + "&email=" + email
+ "&password=" + password;
try {
httpPost.setEntity(new StringEntity(postParameter));
} catch (Exception e) {
}
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
json = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
} catch (ClientProtocolException e) {
} catch (IOException e) {
json = null;
}
Log.d("json", json);
return json;
}
방법 httpGet을 통해 사용자를 등록하는 방법()에 동일한 매개 변수와 이름, 성, 이름, 이메일, 비밀번호 처럼 httpGet()에 동일한 매개 변수를 사용 그것은 당신이 URL에 POST 매개 변수를 추가하고 그것이
`HttpGet _getrequest=new HttpGet("http://aleedex.biz/game/users.php? action=new&"+postParameter);
HttpResponse httpResponse = httpClient.execute(_getrequest);
HttpEntity httpEntity = httpResponse.getEntity();
json = EntityUtils.toString(httpEntity);`
이 시도하는 것이 작동하는 전화를 걸 수 있습니다 여기에 http://aleedex.biz/game/users.php?action=new
아마 나쁜 관행이지만,가 HTTP 헤더에 모든 정보를 넣어 SSL이나 TLS를 사용하여 연결을 암호화 할 수 있습니다. –
어떻게하면 http 헤더에 정보를 넣을 수 없습니까? –
Google을 사용했습니다. http://stackoverflow.com/questions/12358045/java-httppost-request-with-apache-httpclient –