确认预订

时间:2017-02-27 05:32:35

标签: php

这是我自己编写的代码,我无法在预订确认中得到正确的结果。而且我得到了消息"该请求不符合指定的API版本。缺少必需的请求正文"。这个问题困扰了我很长一段时间,严重影响了我的发展进度。请帮帮我

$apiKey = "xxxxxxxx";
    $Secret = "xxxxxx";
                    $signature = hash("sha256", $apiKey.$Secret.time());
                    $curl = curl_init();

                    curl_setopt_array($curl, array(
                      CURLOPT_URL => "https://api.test.hotelbeds.com/hotel-api/1.0/bookings",
                      CURLOPT_RETURNTRANSFER => true,
                      CURLOPT_ENCODING => "",
                      CURLOPT_MAXREDIRS => 10,
                      CURLOPT_TIMEOUT => 30,
                      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                      CURLOPT_CUSTOMREQUEST => "POST",
                      CURLOPT_POSTFIELDS => '<bookingRQ xmlns="http://www.hotelbeds.com/schemas/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <holder name="Titya" surname="Lorn"/>
    <clientReference>001rtr003</clientReference>
    <rooms>
        <room rateKey="20170227|20170228|W|321|60711|TWN.SU|FIT-ASIA-TH-IL|BB||1~1~0||N@5819704BE9BC468DAD19D7B8CB9C351F">
            <paxes>
                <pax roomId="1" type="AD" age="30" name="Titya" surname="Lorn"/>
            </paxes>
        </room>
    </rooms>
</bookingRQ>',

                      CURLOPT_HTTPHEADER => array(
                        "api-key: ".$apiKey,
                        "x-signature: ".$signature,
                        'Content-Type : application/xml',
                        'accept : application/xml'
                      ),
                    ));

                    $response = curl_exec($curl);
                    $err = curl_error($curl);

                    curl_close($curl);
                    try {
                        echo $response;
                    } catch (HttpException $ex) {
                      echo "cURL Error #:" . $err;
                    }

0 个答案:

没有答案