Small white PHP API first experience PHP API documentation PHP API interface development PHP Web AP

Source: Internet
Author: User

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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.