So, I am stumbling a bit since I realized that PHP will not read the body of an HTTP request from a PUT request. And when the header Content-Typein the request is set to application/json, there seems to be no way to get the body.
I use Laravel, which builds its request layer on top of the Symfony2 HttpFoundation lib.
I debugged this a bit using jQuery, and these are some sample queries:
By executing such a request, I can find the content through Input::getContent()
$.ajax({
url: 'http://api.host/profiles/12?access_token=abcdef',
type: 'PUT',
data: {"profiles":[{"name":"yolanda ellis","email":"yolanda.ellis12@example.com"}]}
});
I can not get content from file_get_contents('php://input'). jQuery by default sends data as application/x-www-form-urlencoded.
This becomes even more reasonable when I pass another Content-Type in the request. Same as Ember-Data:
$.ajax({
url: 'http://api.host/profiles/12?access_token=abcdef',
type: 'PUT',
data: {"profiles":[{"name":"yolanda ellis","email":"yolanda.ellis12@example.com"}]},
contentType: 'application/json'
});
, , , . , Ember.js API.
?
Edit
, Chrome DevTools: http://pastebin.com/ZEjDAsmJ
, Laravel.
2:
, , php://input, Content-Type: application/json . , , @Mark_1, , , Laravel.
bshaffer/oauth2-server-php