【发布时间】:2021-06-02 00:48:52
【问题描述】:
我试图获取通过$_POST = json_decode(file_get_contents('php://input')); 传递的原始数据,但file_get_contents('php://input') 给出了一个空字符串(而不是我传递的原始数据)
如果有帮助,请提供更多信息:
- allow_url_fopen 在 php.ini 中开启
- 我正在使用PUT方法发送数据
- 内容类型为
application/json
【问题讨论】:
-
你究竟是如何通过邮递员将此
json数据发送到 php 脚本/函数的? -
很抱歉,我无法理解您的意思。如果这有帮助,数据是 {"name":"some name", "email":"some email"}
-
我的意思是,你在调用任何 api 吗?你能分享带有标题的邮递员屏幕截图吗?这是你提交
PUT请求的那个api的代码吗? -
是的,这是我调用API时访问的代码,我会在问题中附上截图
-
您是否在后端使用任何 php 框架?另外,能否分享
.htaccess(如果正在使用)和生产的apache配置文件
标签: php api postman file-get-contents put