【发布时间】:2021-02-20 02:05:13
【问题描述】:
我试图通过 php 中的不同帖子类型获取值
$data['data'] = 'request';
$data['_REQUEST'] = $_REQUEST;
$data['_POST'] = $_POST;
$data['_SERVER'] = $_SERVER;
header('Content-Type: application/json');
echo json_encode($data);
这是完美的,即使现在在邮递员工作。
在颤振中,我正在尝试遵循脚本,在该脚本中,我编码了正文值以与标头一起发送。
Map<String, String> headers = {
"Content-type": "application/json; charset=UTF-8",
"Accept": "*/*",
"x-auth": auth_token
};
final json = jsonEncode({
"add_view_posty": 'yes',
"post_id":'1'
});
http.Response response = await http.post(url, headers: headers, body: json);
但是 php _REQUEST 和 _POST 帖子类型不会读取上述脚本发送的值。对于上述脚本,我无法访问response.body,但response.status 显示200 响应。
以下 http 请求运行良好,但没有标头。
final json = {
"add_view_posty": 'yes',
"post_id":'1'
};
var data = await http.post(url, body: json);
有人可以帮忙吗,我很感激。谢谢
【问题讨论】: