How to write an interface to display background data on a mobile APP

Source: Internet
Author: User
When I first arrived at a new company, the company's project was mainly for app, and the data on the app was mainly through calling the data interface on the web background, but I have never touched the interface before, the previous tasks were to write program code in the web background and then display it on the page. Now suddenly I am in touch with the interface...

When I first arrived at a new company, the company's project was mainly for app, and the data on the app was mainly through calling the data interface on the web background, but I have never touched the interface before, the previous tasks were to write program code in the web background and display it on the page. now, suddenly I still don't know how to contact the interface.

I would like to ask if the write interface must first implement the corresponding module functions in the web background. the person who writes an interface for the interface and then is responsible for APP development calls this interface directly, what about retrieving data from the database? [Is this the principle]
In comparison: I want to write an interface for updating announcements and security dynamics. Do I need to first develop the functions of these two modules in the web background and then write an interface for them? If so, write the interface based on what data or parameters are required. Format

Reply content:

When I first arrived at a new company, the company's project was mainly for app, and the data on the app was mainly through calling the data interface on the web background, but I have never touched the interface before, the previous tasks were to write program code in the web background and display it on the page. now, suddenly I still don't know how to contact the interface.

I would like to ask if the write interface must first implement the corresponding module functions in the web background. the person who writes an interface for the interface and then is responsible for APP development calls this interface directly, what about retrieving data from the database? [Is this the principle]
In comparison: I want to write an interface for updating announcements and security dynamics. Do I need to first develop the functions of these two modules in the web background and then write an interface for them? If so, write the interface based on what data or parameters are required. Format

Thank you for your invitation. You can use an excuse as a common webpage request or a form request on a webpage, the difference is that the data on the webpage needs to be queried and then rendered to the view file and displayed to the user through a browser. Interfaces query, insert, update, and delete based on different conditions. Then the final result isJsonOrxmlReturn the formatted data to the client.

There should be an interface document for calling an interface, which has the following points:

  1. Interface address

  2. Interface parameters

  3. Status code and data format returned by the API

Go directly to the code!

First, call the interface:

Then the interface code:

This is the data that one project in our project calls in another project. this is what I originally wrote (there should be some unreasonable points, such as the IP address of the verification request. If the interface data is successfully retrieved or fails, a status code is returned.status. I usually return json format, and the front-end and back-end calls can also be parsed.

(Why do we need to pass the name instead of the ID, because the two project data tables have the same user name but different IDs? Hello !~ Do not care too much about details)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.