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
The timing of bidding promotion requires a lot of...
If you have worked in the SEO field for a while, ...
The weather is getting hotter and hotter. I sweat...
1. How long can the new coronavirus survive in a ...
If you could become invisible, what would you do?...
In some reports on overseas games, we often find ...
How to become a favorite concubine in palace dram...
Good copywriting can instantly catch the eye, gri...
Whether we are sales or marketing personnel, we h...
A 17th-century natural history painting of cassav...
This paper mainly analyzes the basic attributes, ...
© JOHN TOWNER Leviathan Press: What's your fa...
Below I will briefly tell you about the black tec...
This article mainly introduces the relevant infor...
For marketers, making marketing plans is a common...