What’s the difference between web and API when standard fun develops API interface in PHP?


1. There are many forms to realize multi interface with single file, such as if elseif… Or switch or dynamic method (that is, the form of TP’s access function body).
Second, JSON is excellent in data output, it has a strong cross platform, JSON supports JSON parsing in the mainstream programming languages in the market, and JSON is gradually replacing XML as the general format of network data.
3、 Interface security, must increase the interface verification. For example, the client side and server side encrypt different interfaces uniformly, while the server side verifies every time the interface needs to be encrypted. Ensure that it will not be used by malicious refresh interface or hackers, especially for large commercial applications.
4. For the online API, it is necessary to ensure that all interfaces run normally and close all error messages = > error_ Reporting (0), and when outputting JSON, no other output is allowed, otherwise, the client will not be able to parse the data, and the app will flash back directly!
5. There are some differences between the development API and web. If it is web, code errors may occur, but it will not lead to particularly serious errors. It may lead to data writing and query failure, and may lead to errors or code confusion in some part of the web. However, if it is API, crash directly!
Customers generally have high requirements for the response speed of the server. Therefore, it is most effective to use the most primitive PHP to complete the interface development. If it is used in the framework, it also needs to load various files without additional requirements. Just like wearing winter clothes in summer, imagine that when you are playing with a mobile phone, any application has to operate, and you have to wait for half a day to have any movement. Can you stand it?
Second, the framework for web development, is a very happy thing, but for the API, you really can’t imagine it will bring you any trouble! In the end, you will feel very painful ~ because many frameworks are created for web.
When developing API interface in PHP, what is the difference between web and API?
Compared with the web, API development is more concise, but the logic may be more complex, because the API only returns results, that is, only completes the data output, and does not render the page.
Web development is more about get and post requests, as well as put and delete requests.
Just like web development, first of all, some related parameters will be passed through the client, which may be get or post. This needs to be mutually agreed by the development team, or a unified specification needs to be specified.
When using parameters, complete data processing according to the needs of the application, such as obtaining user information, sending circle of friends, sending message, submitting data of the end of a game, etc.
When the data logic is processed, it returns the relevant data that the client needs to use, such as user information array, circle of friends list, message status, game result data, and so on. How can the data be returned to the client? Commonly used is XML, JSON, set the corresponding header, and then directly print out the data to be returned.
When the customer gets the data you return, you will interact with the user on the client side.
Source of this article:Biao fan interaction(https://www.biaofun.com/)

Recommended Today

How to Build a Cybersecurity Career

Original text:How to Build a Cybersecurity Career How to build the cause of network security Normative guidelines for building a successful career in the field of information security fromDaniel miesslerstayinformation safetyCreated / updated: December 17, 2019 I’ve been doing itinformation safety(now many people call it network security) it’s been about 20 years, and I’ve spent […]