php处理json请求(php获取post请求的json数据的实现方法)

PHP默认只识别application/x-www.form-urlencoded标准的数据类型,所以,对型如text/xml 或者 soap 或者 application/octet-stream 之类的内容没法解析,若是用$_POST数组来接收就会失败!故保留原型,交给$GLOBALS['HTTP_RAW_POST_DATA'] 来接收html




---------------------------------------------------json

参考:数组

Fiddler进行模拟Post提交json数据,总为null解决方式

Request Headers:app

User-Agent: Fiddler
Host: localhost:3248
Content-Type: application/json; charset=utf-8  
Content-Length: 63url

要加上Content-Type: application/json; charset=utf-8,要不是JSON没效spa

Request Bodycode

{"UserID":4,"UserName":"Parry","UserEmail":"Parry@cnblogs.com"}orm

紧记,不要写成这样:[{"UserID":4,"UserName":"Parry","UserEmail":"Parry@cnblogs.com"}]xml

相关文章
相关标签/搜索