Alamofire. request (. POST, & quot; srxapp. zkkd. comios. phpLoginlogin & quot;, headers: [& quot; token & quot;: token]). responseJSON {(data) in {code ...} 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)} How does the php end accept the token value in headers?
Reply content:
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)} How does the php end accept the token value in headers?
$ _ SERVER ['http _ token']
Getallheaders () ['token'];
getallheaders
Yesapache_request_headers
Is not usednginx
Server, write a simplefunction
.
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'); // if no key is passed, all heads arrays are returned.
All REQUEST data is stored in $ _ REQUEST