使用PHP从Post请求获取有效负载

使用PHP从Post请求获取有效负载,php,perl,rest,post,gzip,Php,Perl,Rest,Post,Gzip,我的Perl脚本正在执行以下POST请求 my $req = $ua->post( $post_target, Content_Type => 'form-data', Content => [ 'data' => [ undef, 'json.gz', 'Content-Type' => '

我的Perl脚本正在执行以下POST请求

my $req = $ua->post(
        $post_target,
        Content_Type => 'form-data',
        Content => [
            'data' => [
                undef,
                'json.gz',
                'Content-Type'     => 'application/json',
                'Content-Encoding' => 'gzip',
                'Content'          => Compress::Zlib::memGzip(encode_json($payload))
            ]
        ]
    );
请求被定向到一个PHP脚本,其编写方式如下:

$input = file_get_contents("php://input");
$filename = 'test';
$filehandle = fopen($filename, 'w');
fwrite($filehandle, $input);
fclose($filehandle);
目前,我无法从POST请求中获取有效负载—甚至一个位都没有—也无法使用gzencode()对输入进行编码,从而抛出“数据错误”


我做错了什么?

只需使用
$\u POST
变量即可

echo "<pre>";    // makes print_r pretty
print_r($_POST); // dumps all of the POST data
echo "</pre>";   
echo $_POST['Content-Type']; //etc ... 
echo”“;//使打印变得漂亮
打印($_POST);//转储所有POST数据
回声“;
echo$_POST['Content-Type']//等

不需要
文件获取内容(“php://input“

你说得对-perl脚本需要分块编码。。这是另一个问题-感谢您的快速响应!