javascript - How to use API

WBOY
Release: 2016-08-08 09:06:57
Original
1070 people have browsed it

It means that I don’t understand how to use API at all. . . I always see it as convenient for others to use, but I don’t know how to use it myself. . .

Reply content:

It means that I don’t understand how to use API at all. . . I always see it as convenient for others to use, but I don’t know how to use it myself. . .

To put it simply, the API interface is an encapsulation of a certain function. It can be encapsulated into a function or a service. For example, for the user order function, I encapsulated the creation of an order into an API interface. Then mobile APP, PC All high-end websites use the order API interface to realize the function of creating orders.
Any interface API has instructions for use, such as the WeChat payment API interface. You pass the order ID, amount and other parameters, and the interface will help achieve successful payment.

<code><?php
/*
*
*这个函数也可以看作是创建订单的API接口,它的功能是创建订单,参数是用户ID 和订单数据
/*
function create_order($user_id=0,$arr_order=[])
{
    //业务代码,去实现创建订单
}
</code>
Copy after login

What API are you referring to?

You can also understand ordinary pages as APIs. This API outputs html code.

Take a bunch of parameters A and replace it with another bunch of parameters B.
Parameter A: {"username":chen,"age":20}
Parameter B: {"status":"ok"}
The intermediate process has been completed

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!