$_POST 只能接收 Content-Type 为 application/x-www-form-urlencoded 和 multipart/form-data 的 POST 数据。
如果你要用 $_POST 的话,你就改一下这里:
header: {
'Content-Type': 'application/json'
}
把上面的 application/json 改成 application/x-www-form-urlencoded (如果要上传文件的话就改成 multipart/form-data,但是微信小程序里的上传文件用的是另外一个 API,具体的你可以仔细看一下文档)。
如果你坚持不改掉 application/json 的话,也不是没有办法,你就用
$input = file_get_contents('php://input');
来读取 POST 过来的数据。
1074

被折叠的 条评论
为什么被折叠?



