我使用file_get_contents('php://input')
检索所有POST参数/从一个特定的网络服务,例如值:解析结果(“PHP://输入”)
$postText = file_get_contents('php://input');
导致这样的事情:
inReplyToId=MG1133&to=61477751386&body=test&from=61477751386&messageId=166594397&rateCode=
然后我需要得到每个单独的键/值对的,因为我需要将它们安置在一个新的数据库记录的字段。例如,我想结束:
$inReplyToId = MG1133
$to = 61477751386
$body = test
一旦我知道了个人价值,我可以在数据库中设置相应的字段。我通常会使用:
if(isset($_POST['inReplyToId']) && $_POST['inReplyToId'] !== '') {
$request->setField('_kf_GatewayMessageID', $_POST['inReplyToId']);
}
但因为它不是正被提交application/x-www-form-urlencoded
形式,将不会在这种情况下工作。
['parse_str()'](http://ch2.php.net/manual/en/function.parse-str.php) – str
http://www.php.net/manual/ en/function.parse-str.php – CBroe
为什么使用'file_get_contents'和'php:// input'?在'INPUT_POST'或'serialize($ _ POST)'上使用[数据过滤器](http://www.php.net/manual/en/book.filter.php)会更好吗?有什么区别? –