PHP Development: The POST method of the REST interface obtains the object submitted by the client.

Source: Internet
Author: User
PHP Development: The POST method of the REST interface obtains the object submitted by the client according to the REST specification, and adds the POST method for data. If you submit an object using the traditional application/x-www-form-urlencoded form, you need to extract the values and values of each field and put them in the parameters. after the server receives the information, then it is restored to the corresponding object for processing, which is additional work for the client and the server.

The best way to transmit objects between the client and the server is to use json or xml. both the client and the server have corresponding tools to serialize or deserialize objects. Individuals prefer json, code is more concise, and conversion is more convenient.

When the client submits a request, set Content-Type to "application/json; charset = UTF-8", tell the SERVER that the message body is json, the SERVER determines $ _ SERVER ['content _ type'], if it is json, use file_get_contents ('php: // input') to obtain the message body. the serialized json string of the object is obtained and processed accordingly.

©2016, frozen fish. please respect the author's Labor achievements, copy and repost, and keep the link on this site! Application Development notes

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.