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
To achieve sustained growth, people must be the f...
When it comes to the most powerful monster in Jou...
This is not a beginner's guide on how to oper...
With regard to information flow advertising, ther...
As the product ecosystem improves, user growth wi...
1. Project Background A domestic financial APP pr...
“You can never cheat the Chinese out of their mon...
In response to the declining sales of Apple iPhon...
Although routines are necessary, you must also be...
One of Huazi's friends blushed and told Huazi...
How much is the quote for beauty makeup productio...
This year, there has been a global chip shortage,...
As long as Apple's IOS system is updated, I u...
It's not that Windows 10 is bad, but Microsoft...
The copywriting is obviously very well written, s...