3
I need to find out what kind of data I’m getting in a user post. The user can provide me the data in XML, JSON HTML and text format Content-Type = text/xml / json / text / html Accept = application/json / xml / text / html
3
I need to find out what kind of data I’m getting in a user post. The user can provide me the data in XML, JSON HTML and text format Content-Type = text/xml / json / text / html Accept = application/json / xml / text / html
4
To check the content-type of a request post
can do:
$_SERVER["CONTENT_TYPE"];
To see the headers server response can do:
print_r(get_headers('/questions/139310/verificando-o-tipo-de-dados-recebido-no-post-em-php'));
Output in this case:
Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: public, max-age=60
[2] => Content-Type: text/html; charset=utf-8
[3] => Expires: Thu, 07 Jul 2016 13:21:56 GMT
[4] => Last-Modified: Thu, 07 Jul 2016 13:20:56 GMT
[5] => X-Frame-Options: SAMEORIGIN
[6] => X-Request-Guid: 79b68547-ba8b-40fc-973f-fff0e2286f7d
[7] => Content-Length: 53578
[8] => Accept-Ranges: bytes
[9] => Date: Thu, 07 Jul 2016 13:20:56 GMT
[10] => Via: 1.1 varnish
[11] => Age: 0
[12] => Connection: close
[13] => X-Served-By: cache-fra1230-FRA
[14] => X-Cache: MISS
[15] => X-Cache-Hits: 0
[16] => X-Timer: S1467897656.395677,VS0,VE99
[17] => Vary: *
[18] => X-DNS-Prefetch-Control: off
[19] => Set-Cookie: prov=1c178290-fa4b-4210-c876-98a0cddcbc11; domain=.stackoverflow.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
)
Among them is in Content-Type
Browser other questions tagged php html json xml
You are not signed in. Login or sign up in order to post.