How to write an interface to make background data appear on the phone app

Source: Internet
Author: User

Just to a new company, the company's project is mainly to do the app, the data on the app is mainly through the call of the Web backend data interface, but has never been exposed to the interface, the previous thing is to write in the Web spooler code, and then displayed on the page, Now suddenly I touch the interface really do not know how to do.

I want to ask is, write interface is not first in the web background to the corresponding module function, in for him to write an interface and then responsible for the development of the app, directly call this interface, from the database fetch data? "Is that the way it works?"
than on: I want to write an update bulletin, security dynamic interface, is not first in the web background to the two module function to make, and then to their respective write an interface ah? If this is the case, write the interface according to what you need to use the data or parameters. What is the format?

Reply content:

Just to a new company, the company's project is mainly to do the app, the data on the app is mainly through the call of the Web backend data interface, but has never been exposed to the interface, the previous thing is to write in the Web spooler code, and then displayed on the page, Now suddenly I touch the interface really do not know how to do.

I want to ask is, write interface is not first in the web background to the corresponding module function, in for him to write an interface and then responsible for the development of the app, directly call this interface, from the database fetch data? "Is that the way it works?"
than on: I want to write an update bulletin, security dynamic interface, is not first in the web background to the two module function to make, and then to their respective write an interface ah? If this is the case, write the interface according to what you need to use the data or parameters. What is the format?

Thank you for inviting me. Very simple, you can use the pretext as a normal page request, or the usual page of the form request, the difference is that the data on the usual page needs you to query out after rendering to the view file through the browser display to the user. And the interface is based on different criteria query, insert, UPDATE, delete. The final result is then returned to the client in the Json xml form of data or format.

The calling interface should have an interface document, which is roughly the following:

    1. Address of the Account interface

    2. Parameters of the interface

    3. The status code returned by the interface and the data format

Or go straight to the code!

First call the interface:

Then the code for the interface:

This is a project in our project called the data in another project, which I wrote originally (should also have unreasonable place, such as authentication request IP, etc.) probably should be like this. Fetch interface data successfully or unsuccessfully returns a recognized status code, such as what I'm using here status . And my return is generally JSON-formatted, front-end and back-end invocation of parsing.

(As for why you should pass the name instead of the ID, because the two project data table usernames are the same but the IDs are different.) ~ Don't 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.