How to send post request in php with headers

I am trying to do a post request with post field data for a certain url with custom headers.

This is the orignal data from wireshark

POST /api.php HTTP/1.1
Content-Length: 119
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Host: test.com
Connection: Keep-Alive
Accept-Encoding: gzip

data=7483478927389273

I tried but it keeps giving me

Warning: file_get_contents(http://test.com/api.php): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

This is what I have tried so far based on some articles on here stackover flow

<?php
$url = 'http://test.com/api.php';
$data = array('data' => '7483478927389273');

// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'method'  => 'POST',
        'Content-Length'  => "119\r\n",
        'Content-Type' => "application/x-www-form-urlencoded; charset=UTF-8\r\n",
        'Host'  => "test.com\r\n",
        'Connection'  => "Keep-Alive\r\n",
        'Accept-Encoding'  => "gzip\r\n",
        
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }

var_dump($result);

Please help me as I am a beginner. Thank you