读取原始post数据,这对于从flashxmlsocket获取XML非常有用。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了读取原始post数据,这对于从flashxmlsocket获取XML非常有用。相关的知识,希望对你有一定的参考价值。
Often php can't interpret POST data because it is not form-encoded. This is typical when the post data is XML from API's like Flash's XmlSocket. You can use the following methods to read the POST data directly.
/** Using php://input ----------------- Version: 4.3+ Reading [php://input][1] is the preferred method since PHP 4.3. The Content-Type header of the posted content must _NOT_ be application/x-www.form-urlencoded or multipart/form-data. For XML you can use the Content-Type: text/xml. [1]: http://us2.php.net/manual/en/wrappers.php.php */ // Make sure the user is posting if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { // Read the input from stdin } /** Using $HTTP_RAW_POST_DATA ------------------------- Version 3.0+ __Note__: Reading php://input is preferred. As with php://input, the Content-Type header of the posted content must _NOT_ be application/x-www.form-urlencoded or multipart/form-data. PHP 4.1+ ~~~~~~~~ You can also enable [always-populate-raw-post-data][1] in the php.ini to have the value always populated reguardless of Content-Type. However since this requires config changes it is less portable. [1]: http://us2.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data */ $postText = $GLOBALS['HTTP_RAW_POST_DATA'];
以上是关于读取原始post数据,这对于从flashxmlsocket获取XML非常有用。的主要内容,如果未能解决你的问题,请参考以下文章
使用 Postman 通过原始 JSON 发送 POST 数据