【发布时间】:2012-03-01 09:07:37
【问题描述】:
框架在这里 http://luracast.com/products/restler/
我在工作中使用restler 作为restful api, 当我使用主干模型保存到 url 时,它使用“HTTP PUT”请求方法将我的数据作为 json 发送和更新,我想从我输入的内容中得到响应......
如果它是我可以使用的 HTTP POST 请求方法
// to getting content from a POST
$post_data = json_decode(file_get_contents('php://input'), true);
获取我的内容,但无法从 HTTP PUT 获取任何内容
// can't get anything from a PUT
function putpatients($id) {
$post_data = file_get_contents('php://input');
$post_data = json_decode($post_data, true);
echo $post_data['name'];
}
浏览器响应空白
如何将我的数据返回为 json ???
【问题讨论】:
-
抱歉,不确定问题所在。 input 是空白的吗? 输出 是空白的吗?客户端是空白的吗?
-
php://input是一个流,如果你从中读取,它将清空它。你可能已经读过它了吗?如果是这种情况,第二个file_get_contents('php://input')将返回''
标签: php rest backbone.js