如何使用php和cURL从Web服务获得响应

I am trying to connect to a web service with cURL and PHP. This is my code, along with the form for the user input.:

<?php
if (isset($_POST['submit'])) {
    date_default_timezone_set('Europe/Sofia');
    $hotelID = 1;
    $userName = 'admin';
    $password = 'admin';
    $url = 'http://serviceurl.com/someservice/freerooms.svc';
    $requestTime = date('d.m.Y H:m:s');
    $tempFromDate = date_create($_POST['fromDate']);
    $tempToDate = date_create($_POST['toDate']);
    $fromDate = date_format($tempFromDate, 'd.m.Y H:m:s' );
    $toDate = date_format($tempToDate, 'd.m.Y H:m:s' );
    $data = array(
        'fromDate' => $fromDate,
        'toDate' => $toDate,
        'hotelID' => $hotelID,
        'requestTime' => $requestTime,
        'userName' => $userName,
    );
    $token = md5(md5($password . $requestTime));

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    echo $token . '<br>';
    echo curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
    $response = curl_exec($ch);
    if (!$response) {
        $error = curl_error($ch);
    }
    curl_close($ch);

    $result = json_decode($response,true);
    print_r($result);

}

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Site</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div id="wrapper" class="col-md-10 col-md-offset-1" style="position: absolute; top: 40%; left: 20%;">
    <div id="form-messages">
        <?php
        if(isset($error)) {
            echo '<b>Error: </b>' . $error;
        } else {
            $error = null;
        }
        ?>
    </div>
    <form action="" method="post" class="form-inline" id="form">
        <div class="form-group">
            <input type="date" name="fromDate" required>
        </div>
        <div class="form-group">
            <input type="date" name="toDate" required>
        </div>
        <button type="submit" name="submit">Submit</button>
    </form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
</body>
</html>

Problem is, I don't have access to the service from the back end. All the person that maintains it has told me, is the format of the data that should be submitted, and that the response will be in JSON format. This is for hotel room reservation. I am told that I should submit the data in the headers along with the token. When I submit this code, I get an empty response, with an error, stating that the token is INVALID. It's the first time I've been working with cURL and RESTful services, so any help is welcome.