<?php
$host = '54.85.96.159';
$port = 5001;
$data = [
    "email" => "dilipkumar.gupta@reseit.in",
    "cost" => 5
];

$jsonData = json_encode($data);
$fp = fsockopen($host, $port, $errno, $errstr, 30);

if (!$fp) {
    echo "Error: $errno - $errstr<br />\n";
} else {
    $out = "POST /tokens/allocation HTTP/1.1\r\n";
    $out .= "Host: $host\r\n";
    $out .= "Content-Type: application/json\r\n";
    $out .= "Content-Length: " . strlen($jsonData) . "\r\n";
    $out .= "Connection: Close\r\n\r\n";
    $out .= $jsonData;

    fwrite($fp, $out);
    $response = '';

    while (!feof($fp)) {
        $response .= fgets($fp, 128);
    }

    fclose($fp);

    echo "Response: $response";
}
?>