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

相關文章
相關標籤/搜索