Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="login.php" method="post" id="clientLogin" onsubmit="return C1heckFields()">
- <!--?php csrf_token(); ?-->
- <strong></strong>
- <br>
- <div>
- <label for="email">Логин:</label>
- <input id="myl" type="text" name="login" size="16" value="">
- </div>
- <div>
- <label for="ticketno">Пароль:</label>
- <input id="ticketno" type="password" name="password" size="16" value="">
- </div>
- <p>
- <input class="btn" type="submit" value="Войти">
- </p>
- </form>
- class ApplicationsAuth extends AsyncTask<Void, Void, Void> {
- protected Map<String, String> applicationsAuthCookies = null;
- protected String userLogin;
- protected String userPassword;
- protected String userName;
- public ApplicationsAuth(String login, String password)
- {
- this.userLogin = login;
- this.userPassword = password;
- }
- @Override
- protected Void doInBackground(Void... params) {
- Document testPage = null;
- Connection.Response authStartResponse = null;
- Connection.Response authFinalResponse = null;
- try {
- authStartResponse = Jsoup.connect("http://support.tltsu.ru/")
- .method(Connection.Method.GET)
- .timeout(3500)
- .execute();
- try {
- authFinalResponse = Jsoup.connect("http://support.tltsu.ru/login.php")
- .timeout(3500)
- .data("login", userLogin)
- .data("password", userPassword)
- .method(Connection.Method.POST)
- .cookies(authStartResponse.cookies())
- .execute();
- applicationsAuthCookies = authStartResponse.cookies();
- testPage = authFinalResponse.parse();
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- if (applicationsAuthCookies != null) {
- testPage = Jsoup.connect("http://support.tltsu.ru/")
- .cookies(applicationsAuthCookies)
- .timeout(3000)
- .get();
- userName = testPage.select("div#container > div#header > p").text();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
- @Override
- protected void onPostExecute(Void result) {
- super.onPostExecute(result);
- }
- }
Add Comment
Please, Sign In to add comment