저희 대학교 어플을 만들어보고자 하여서 혼자 개발 중입니다.
홈페이지 대학교포털에 로그인을 앱에서 post를 이용하여 로그인을 하려고 하는데
아이디와 패스워드를 입력 후 로그인을 누르면
대학교포털에 아이디와 비밀번호를 전송하여 로그인을 한 후
성공 -> 웹 오픈
실패 -> 로그인 실패
로 개발을 하였습니다. 하지만 아무렇게나 치고 로그인을 해도 성공이되고있는데
뭐가 문제인지 알려주시면 감사하겠습니다.
try{
URL url = new URL("https://portal.jnu.ac.kr/Common/Login/Login.aspx");
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
String postData = "ucLogin_userid1=" + URLEncoder.encode(userid)
+ "&ucLogin_passwd1=" + URLEncoder.encode(password);
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(postData.getBytes("UTF-8"));
outputStream.flush();
outputStream.close();
InputStream inputStream;
if(httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
inputStream = httpURLConnection.getInputStream();
else
inputStream = httpURLConnection.getErrorStream();
final String result = loginResult(inputStream);
handler.post(new Runnable() {
@Override
public void run() {
if(result.equalsIgnoreCase("fail")){
tv.setText("로그인이 실패했습니다.");
}
else{
tv.setText("Admin님 로그인 성공");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse( "-----------" ));
startActivity(intent);
}
}
});
} catch (MalformedURLException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
}