I don’t quite understand the real difference between the web and api methods.
I just think that the web method corresponds to the front-end rendering using the browser, while the api corresponds to the mobile phone/tablet using the app.
Moreover, the web method can be natural and easy Maintain state (session, cookie) manually, while API is stateless, but you can manually maintain state with token.
I don’t know if this understanding is correct? [Question 1]
Is there an ajax problem with the api method? 【Question 2】
I used laravel to make a rudimentary prototype of a website bit by bit (naturally in web mode), and I am considering developing the corresponding mobile/tablet app front-end in the future. At this time, I wonder if I can remove all web access, regardless of browser The app still connects to the backend (server) through the API. In this way, I don't need to develop the web backend, I only need to develop the API backend.
Is this possible? 【Question 3】
Is this easy to implement? [Question 4]
Is this a common industry practice? 【Question 5】
Thank you in advance!
黄舟2017-05-16 16:49:25
Question 1: Basically correct. Using a token does not count as maintaining state, it is just a temporary access token.
Question 2: The back-end API does not care whether the front-end is ajax. After all, ajax is just a web technology, and the API can receive various types of HTTP requests. The only thing you need to pay attention to with web ajax is the cross-domain issue.
Question 3: Of course it is possible, this is a typical front-end and back-end separated web development.
Question 4: Easy. The front-end and back-end can be developed completely independently. They only need to agree on the API interface.
Question 5: In fact, it has been common for a long time, but it is good that you can realize this independently.
给我你的怀抱2017-05-16 16:49:25
Of course, all interactions between the front end and the server are conducted through the API interface
怪我咯2017-05-16 16:49:25
Regarding the problem of using the same set of code api implementation on the PC side and the app side, there are advantages and disadvantages. Because the app is limited by the interface, the content presented should still be different from that on the PC, so it is better to maintain the implementation separately. Of course There is also a disadvantage, that is, when modifying the code, you need to modify two places, so you still have to look at your own comprehensive considerations
曾经蜡笔没有小新2017-05-16 16:49:25
I feel that if the product service needs to be extended to many platforms, then it should be developed using API. Moreover, the functions and content of each platform are highly coupled.
If the website has many functions and the operation is mainly based on the website, but the APP is much simplified, you can also make an API for the APP independently at this time. It is more efficient to develop the website in the traditional way.
PHP中文网2017-05-16 16:49:25
The separation of front-end and back-end is not very friendly to SEO.
In order to take into account SEO and the separation of front-end and back-end, it is a bit time-consuming to change the language of the back-end