Swift-how does php receive the number of requests in the request header of the ios client?

Source: Internet
Author: User
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'];

getallheadersYesapache_request_headersIs not usednginxServer, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.