$ _POST参数已被修改/截断 [英] $_POST param was modified/truncated
问题描述
当我在POST中将数据发送到php脚本时,该帖子数据已被截断/修改...
When I send data in POST to a php script this post data was truncated/modified ...
我有一个变量$ encrypted用Guzzle或Curl发送到一个端点,该端点返回json中的发布数据(例如)
I have a variable $encrypted sent with Guzzle or Curl to an endpoint which return post data in json (for example)
echo json_encode($_POST);
$在发送前已加密:
string(88) "D4PYDZou2pEugJKyR0vpjpdKplQ0g/pxNOrqomImFgdtKjuKA3WAQuFAt3OUlghBnGpMz2dOnYGOkGUyz5Vd7g=="
从端点收到的$ encrypted
$encrypted received from endpoint
string(71) "D PYDZou2pEugJKyR0vpjpdKplQ0g/pxNOrqomImFgdtKjuKA3WAQuFAt3OUlghBnGpMz2d"
当我使用file_get_contents("php://input")检查RAW数据时;
when I check RAW data with file_get_contents("php://input");
$ encrypted可以,但不能在$ _POST中使用...
$encrypted is OK but not in $_POST ...
我的脚本由apache/php通过nginx运行
My script is running by apache/php through nginx
谢谢.
雷米
推荐答案
我找到了发布base64数据的解决方案.
I found a solution to post base64 data.
function base64_urlencode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64_urldecode($data)
{
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
此方法避免在字符串中使用特殊字符.
this methods avoid special chars in string.
这篇关于$ _POST参数已被修改/截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!