Closed lordGuan closed 6 years ago
GET的请求 可以直接在function的参数中传递 其他参数会在file_get_contents('php://input')里 不知道你的是什么方式的请求
做了兼容 GET参数也可在 $this->getParam中获取 优先级GET > data数据
我查了很多文章,也没有搞清楚为什么file_get_contents('php://input')获取不到数据
POST的情况下能正常获取吗 还是只有 PUT DELETE 这种会获取失败 感觉是不是跟php配置或者php临时缓存的读写权限有关
刚才我又确认了一下,从页面用ajax进行PUT是OK的,用phpstorm的工具和postman就不行。POST请求时没有问题的。
是不是被csrf拦截了?页面ajax里有注册csrf验证信息的 在action里添加 protected $csrfValidate = false; 绕过csrf 验证看看
并不好使(捂脸 刚才我抓了一下postman和phpstorm的请求,发现content-length都是0,会是这个的影响么
Content-Type 设置成 application/x-www-form-urlencoded ? 数据传 abc=123&cba=321这种 如果是application/json 的话 数据应该传json {“abc”:123} 类似这种
果了个然,restful client我没加content-type,参数得用text才能传的了。postman的Content-Type倒是没问题,但是body默认的form-data。原来如此,学到了学到了
action开启了RESTful Api在初始化时this->param是通过file_get_contents('php://input')赋值的,但是我多次调试发现file_get_contents('php://input')是没有内容,不知道是什么情况