您好,欢迎访问一九零五行业门户网

swift - 求大牛 解答php 怎么接收ios端request请求中 头部的产数

alamofire.request(.post, http://srxapp.zkkd.com/ios.php/login/login, headers: [token:token]).responsejson { (data) in
let json = json(data: data.data!) print(json)}php端怎么接受 headers 里面的 token值呢

回复内容: alamofire.request(.post, http://srxapp.zkkd.com/ios.php/login/login, headers: [token:token]).responsejson { (data) in
let json = json(data: data.data!) print(json)}php端怎么接受 headers 里面的 token值呢

$_server['http_token']
getallheaders()['token'];
getallheaders 是 apache_request_headers 的别名,不能用于 nginx 服务器,自己简单写一个function 获取。
function request_header($key = null){ $all_headers = []; foreach ($_server as $name => $value) { if (substr($name, 0, 5) == 'http_') { $all_headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; } } return is_null($key) ? $all_headers : (isset($all_headers[$key]) ? $all_headers[$key] : null);}request_header('token'); // 不传key返回所有heads数组
所有请求数据都在$_request中放的
其它类似信息

推荐信息