-2

We are sending a POST type http request with information in header as follows:

POST /Inbound_sms_peerless.php HTTP/1.1 Request Method: POST Request URI: /Inbound_sms_peerless.php Request Version: HTTP/1.1 Accept: application/json Content-Type: application/json User-Agent: Jersey/2.23.2 (HttpUrlConnection 1.8.0_60) Host: www.sms.gnyservices.com Connection: keep-alive Content-Length: 120 [Full request URI: http://www.example.com/Inbound_sms_peerless.php]

Request Header : {"from":"+13126477409","recipients":["+19298005992"],"ccRecipients":[],"text":"Sajjad","mediaURL":null,"contentId":null}

My question is how can i read the request header values in php?

user1911703
  • 740
  • 5
  • 8
  • 24

1 Answers1

0

You can read the HTTP request headers with get_headers().

Progman
  • 16,827
  • 6
  • 33
  • 48
  • Output of get_headers() try get_headers getheaders: 0 => HTTP/1.1 200 OK getheaders: 1 => Date: Tue, 15 May 2018 21:07:44 GMT getheaders: 2 => Server: Apache getheaders: 3 => X-Content-Type-Options: nosniff getheaders: 4 => Vary: Accept-Encoding getheaders: 5 => Content-Length: 0 getheaders: 6 => Connection: close getheaders: 7 => Content-Type: text/html; charset=UTF-8 but i don't see any values of the following line Request Header : {"from":"+13126477409","recipients":["+19298005992"],"ccRecipients":[],"text":"Sajjad","mediaURL":null,"contentId":null} want to read these – user1911703 May 15 '18 at 21:09
  • Check https://stackoverflow.com/q/8945879/286934 on how to read the request body for POST requests. – Progman May 15 '18 at 22:05