How do you use the RESTful API from PHP?

I tried searching, but cannot figure out how to access the data through the RESTful interface. I am only looking for sample code that shows that someone is accessing some data from some imaginary web service using its API. A simple explanation of “how it works” would also be helpful.

+3
source share
6 answers

Kind of hot topic. Expect an explosion of answers;)

REST works on the principle of using HTTP request methods to determine the action of an application (REST server) on an object. Usually 4 HTTP methods are used: GET, POST, PUT and DELETE.

, , , , . URL- REST http://mydomain.com/services/user

, GET http://mydomain.com/services/user/someuserid.

, POST http://mydomain.com/services/user, .

, PUT http://mydomain.com/services/user/someuserid. , .

, DELETE http://mydomain.com/services/user/someuserid

, 4 HTTP- , , , RESTful:

  • GET == get, fetch, retrieve
  • POST == create, add
  • PUT == ,
  • DELETE == ,
+2

- , .

RESTful HTTP :

  • HTTP GET URL- API.
  • , http header "Content-Type".
  • ?
  • , , .
  • , .
  • , HTTP GET POST , . 3.
  • , .
+3

API Sun Cloud. AFAIK ( ) API, hypermedia (HATEOAS) . , , REST, .

Sun Cloud , , .

+1

, , SOAP, " " " -", . REST , .

WebRequest POST GET . XML , LINQ to XML XML Serialization, - , . , , XML.

. "" REST .NET, 1" (, ).

-1

Source: https://habr.com/ru/post/1715560/


All Articles