1. What problem does this article solve and what can we learn? I am working on a hospital affairs system project recently, so I will record the process of learning new knowledge. This article is about the login operation. I originally thought that the login process was a relatively simple thing, but after a deeper understanding, it is still difficult: 1. To obtain the verification code photo during the login process, use the HTTP get operation. To pass the parameters to the server, you need to use post. 2. The above get and post operations can be implemented using many current network frameworks, such as volley, but after obtaining the verification code photo, a session must be maintained. Therefore, after consulting the information, it is more convenient and quick to use the okhttp framework to build this project. Let's first learn how to use okhttp: http://blog.csdn.net/itachi85/article/details/51190687 There is also a quick start to load photos using okhttp: http://blog.csdn.net/bo543937071/article/details/53380651 2. Q: What are sessions and cookies? Simply put, cookie is the session ID of the client, and session is the session ID of the server. Based on this ID number, you can query the content of your session. (To learn more about cookies and sessions, click here) http://blog.csdn.net/androidxiaogang/article/details/51925388 In this project, we need to obtain the verification code photo. Because each time you refresh the verification code URL, a different verification code photo will appear, so you need to save the verification code session, otherwise how can others know which verification code you have a "session" with. First, the photo: As shown in the figure, it is divided into four steps, which is easier to understand with text: 1. The client sends a request for a verification code photo, and brings back the photo and a jsessionid field that is stored in the user's cookie. 2. We take out the session from the cookie header, and then pack the parameters and send it along with the session so that the server knows who sent it. The four steps and two points of summary make it easier to understand with the code. 3. Analyze some important codes and then paste all the codes Let's take a look at the data given to us by the backend. There is url_randCodeImage used to send a get request to obtain photos, and url_login used to post data. These are the data we want to package and send: And our xml interface First, we get our verification code photo and load the picture asynchronously
After getting the photos and session, we package and send the data:
***Let's take a look at the information logged out after we successfully logged in *** Here is our full code, I hope it will be helpful to those who don’t understand the process: Continue |
<<: Building iOS Routers Step by Step
>>: iOS Developer Account Summary
After get off work on November 20, the Ministry o...
On the surface, it is difficult to find a corner ...
In the preface to Puzzling Mathematics, authors G...
From June 5th to 6th, the 2018 (9th) Global Autom...
In the process of developing mobile client, espec...
The product has hit a bottleneck and the order vo...
In 2010, the tablet computer was born under the c...
Drinking water is an essential part of our daily l...
As the 2022 Android flagships debut one after ano...
As people's living standards improve, obtaini...
The traditional auto industry is continuously inc...
On June 25, my country's Chang'e-6 return...
We have now entered the flood season, and many pl...
Recently, the temperature in many parts of the co...
This is a golden age of creativity. We believe th...