The PHP write API here actually refers to providing a webservice
1.2.1.以json/Xml2.3.用来实现不同平台的交互
How to begin
To say the simple point, is to pass the data, is to encapsulate various methods for other people to call
A Simple Example
How to write a Student rice card interface?
As a middle tier, we need to get the user's data (i.e. student student number, student card password), and know where we should post the data (such as Www.123.com/Api/login), and understand the data format, we can start.
The process is that the user input the user name and password entered into the form, we received the user name and password, and then written in the required data format, such as Username= "&password=", and then through the curl to achieve the interaction with the server
$ch = curl_init(); curl_setopt($ch$url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($chtrue); curl_setopt($ch$fields_all); $data = curl_exec($ch); curl_close($ch);
Here are some key interaction codes, where $fields_all represents a part of a URL request written in data format that has been encoded by UrlEncode. While $fields represents the name of each data variable in $fields_all
The server will then be presented with a returned JSON data, and the success of the interactive data is at a glance.
Of course, this is only the simplest interaction, you may also encounter other logic is more chaotic, you can only think slowly, in fact, write a website to write the habit of writing the API is pretty simple, but there is no sense of accomplishment ....
Of course this is not based on any restful style, the next one is about the rest experience ... Of course, Yii and Laravel use framework development is also very exciting, after all, others support rest.
Written by pure novice, lightly sprayed.
--by vampirebitter
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above introduces the small white PHP API first experience, including the api,php aspects of the content, I hope that the PHP tutorial interested in a friend to help.