Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- String account = params[0].get(0);
- String password = params[0].get(1);
- URL url = new URL("http", WEB_SERVICE_URL, PORT, REST_LOGIN);
- HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
- httpURLConnection.setConnectTimeout(CONNECTION_TIMEOUT);
- httpURLConnection.setRequestMethod("POST");
- httpURLConnection.setDoOutput(true);
- httpURLConnection.setRequestProperty("Content-Type", "application/json");
- httpURLConnection.setRequestProperty("Accept", "application/json");
- JSONObject json = jsonParser.serialJsonLogin(nomCompte, motPasse);
- osw = new OutputStreamWriter(httpURLConnection.getOutputStream(),"UTF-8");
- osw.write(json.toString());
- osw.flush();
- String body = readStream(httpURLConnection.getInputStream());
- osw.close();
- Log.i(TAG, "Return : " + body);
- user = jsonParser.deserializeJsonUser(body);
- }catch (Exception e) {
- mException = e;
- }finally {
- if (mHttpURLConnection != null) {
- mHttpURLConnection.disconnect();
- }
- }
- return user;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement