Reputation: 367
When I send data in POST to a php script this post data was truncated/modified ...
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);
$encrypted before sending:
string(88) "D4PYDZou2pEugJKyR0vpjpdKplQ0g/pxNOrqomImFgdtKjuKA3WAQuFAt3OUlghBnGpMz2dOnYGOkGUyz5Vd7g=="
$encrypted received from endpoint
string(71) "D PYDZou2pEugJKyR0vpjpdKplQ0g/pxNOrqomImFgdtKjuKA3WAQuFAt3OUlghBnGpMz2d"
when I check RAW data with file_get_contents("php://input");
$encrypted is OK but not in $_POST ...
My script is running by apache/php through nginx
Thx.
Remi
Upvotes: 0
Views: 222
Reputation: 367
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.
Upvotes: 1