C
C
Chesterfield252021-12-07 01:36:24
Java
Chesterfield25, 2021-12-07 01:36:24

Is it possible to send a post request to a form?

I am creating an application from the site using this library for android https://github.com/VishnuSivadasVS/Advanced-HttpUR...
The video is quite clear, but it shows how to log in by directing the user to the post executor file or get requests register.php endlogin.php. Is it possible to use this or a similar library to make the post request not be sent to a direct executor file, but let's say send a post request to such a link? b99437dx.beget.tech/account/login

Here's what I got but authorization fails

login_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final String username;
                final String password;

                username = String.valueOf(inputUsername.getText());
                password = String.valueOf(inputPassword.getText());
                if(!username.equals("") && !password.equals("")) {
                    Handler handler = new Handler();
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            String[] field = new String[2];
                            field[0] = "user_name";
                            field[1] = "password";
                            String[] data = new String[2];
                            data[0] = username;
                            data[1] = password;
                            PutData putData = new PutData("http://b99437dx.beget.tech/account/login", "POST", field, data);
                            if(putData.startPut()) {
                                if(putData.onComplete()) {
                                    String result = putData.getResult();
                                    if(result.equals("")){
                                        Toast.makeText(getApplicationContext(), "SUCCESS!", Toast.LENGTH_SHORT).show();
                                        startActivity(new Intent(getApplicationContext(), MainActivity.class));
                                        finish();
                                    }
                                }
                            }


                        }
                    });
                }
            }
        });


I would be grateful if you could tell me similar libraries for android so that you can send requests directly to the field on the site

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jacen11, 2021-12-07
@Jacen11

the post request was not sent to a direct file
whatoooo
send a post request to this link
Well, yes,
where did you find this strange liba from? how did you even manage to skip the standard solutions and choose an outdated lib that literally 20 people downloaded all the time?
so that you can send requests directly to the field on the site
what kind of nonsense is this , in
short, you basically do not understand how the web works. With the help of this form, the front will send a request, then you need to repeat it. Start with simpler and more modern guides

O
Orkhan, 2021-12-07
Hasanly @azerphoenix

I would be grateful if you could tell me similar libraries for android so that you can send requests directly to the field on the site

Good afternoon.
HTTP requests do not work with the client side (with the form displayed in the browser), but with the server side. Those. using http methods you communicate with the server.
Accordingly, open the form in question and the browser console and see where exactly this form sends a post request (to which endpoint). Also see what data it sends with a POST request.
Hint:
fpsqEQ4.png
But note that in addition to the data from the form, there are also cookies that must also be sent.
Liba itself is better to change to something else.
And in general, if you plan to work with either from the application, then you should think about implementing a REST API with jwt authorization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question