In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to create an API-centric Web application, in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Are you planning to start a new web application? In this tutorial, we will discuss how to create API-centric web applications and explain why such applications are important in today's multi-platform world.
Introduction
API?
For those who are not familiar with the term, API is short for Application Programming Interface (Application programming Interface). According to Wikipedia:
API is a source code-based convention that is used for interfaces between software components to communicate with each other. API may contain conventions for functions, data structures, object classes, variables, and so on.
API visualization
The picture is in favor of http://blog.zoho.com
Simply put, API refers to a set of functions in an application that can be used by other applications (or the applications to which these functions belong, as we will see below) to interact with applications. API is a great way to safely and properly demonstrate its functionality to external applications, because all the functions available to these external applications are limited to those shown in API.
What is a "API-centric" network application?
API-centric network applications are basically a kind of network applications that perform most or even all functions through API calls.
API-centric network applications are basically a kind of network applications that perform most or even all functions through API calls. For example, if you are about to log in to a user, you should send his authentication information to API, and API will return a result indicating whether the user provided the correct username-password combination.
Another feature of API-centric web applications is that API has always been stateless, which means that such applications cannot identify API calls initiated by sessions. Because API calls are usually made up of back-end code, it will be difficult to take control of the session because there is usually no cookies involved. This limitation is actually a good thing-it "forces" developers to build API that does not work based on the current user state, but functionally, it makes testing easy because the user's current state does not need to be rebuilt.
Why go through all these troubles?
As Web developers, we have witnessed technological advances. There is a common sense that modern people will not only use applications through browsers, but also through other devices such as mobile phones and tablets. For example, the article, titled "users spend more time on mobile apps than on the web," published on Mashable:
For the first time, users spend more time on mobile apps than on the Internet, according to a new report.
Flurry compared its mobile data with statistics from comScore and Alexa and found that in June, users spent 81 minutes a day using mobile apps and only 74 minutes surfing the web.
There is also an updated article from ReadWriteWeb, "more people surf the web on mobile devices than use IE6 and IE7 combined":
The latest data from Sitepoint browser trends show that more people browse Web on smartphones than on IE6 and IE7. These two hard-to-improve antiques have been a nightmare for Web developers for years, and they need to downgrade websites as properly as possible to a level that at least common browsers can support. But times have changed: in November 2011, 6.95 per cent of Web activity took place on mobile browsers, compared with 6.49 per cent on IE6 or IE7.
As we can see, more and more people are getting information through other ways, especially mobile devices.
What does this have to do with my creation of API-centric web applications?
This will certainly make our application more useful, because it can be used wherever you need it.
One of the main advantages of creating API-centric web applications is that it helps you build features that can be used on any device, browsers, mobile phones, and even desktop applications. All you need to do is create an API that enables all these devices to communicate with it, and then, look! You will be able to build a centralized application that can accept input from any device used by the user and perform the corresponding functions.
Block diagram of API-centric application
By creating applications in this way, we can take advantage of the fact that different people use different media. This is bound to make the application more useful because it can be used wherever users need it.
To prove our point, here is an article about Twitter's redesigned website that tells us how they are now using their API to drive Twitter.com, essentially API-centric:
One of the most important architectural changes is that Twitter.com is now a customer of our own API. It extracts data from the terminal, which is the same endpoint that we use for iPhone, iPad, Android, and all third-party applications. This shift enabled us to allocate more resources to the API team and generated more than 40 patches at the same time. On the initial page load and each call from the client, all data is now fetched from a highly optimized JSON segment cache.
In this tutorial, we will create a simple TODO list application that centers on API, and a front-end client on the browser that interacts with our TODO list application. At the end of the article, you can learn about the organic components of an API-centric application, as well as how to make secure communication between the application and the client easier. Remember this, let's get started!
Step 1: plan the functionality of the application
The TODO application we will build in this tutorial will have the following basic CRUD functions:
Create a TODO entry
Read TODO entry
Update the TODO entry (renamed, marked as complete, marked as incomplete)
Delete TODO entry
Each TODO entry will have:
A title Title
A due date Date Due
A description of Description
A flag Is Done that determines whether the TODO entry is completed
Let's simulate the application so that we can have an intuitive reference when we consider what the application will look like in the future:
Simple TODO simulation example
Step 2: create an API server
Since we are developing an API-centric application, we will create two "projects": the API server and the front-end client. Let's start by creating an API server.
In your web server folder, create a folder, name it simpletodo_api, and then create an index.php file. This index.php file will act as a front-end controller to access the API, so all requests to access the API server will be generated by this file. Open it and enter the following code:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.