post the data using curl for expedia booking onsite

I am posting one request through one api for onsite booking.
When I am posting the data through one form action and submit that I will get the response.
But when I am trying to post same url through the curl to get the response I am not getting any data .

The url is :-

Read More
https://book.api.ean.com/ean-services/rs/hotel/v3/res?
minorRev=99
&cid=55505
&sig=1893d9f7e3e9fbd3f8a36f43cd61287d
&apiKey=1bn8n4or4tjajq23fe4l6m18lp
&customerUserAgent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
&customerIpAddress=223.30.152.118
&customerSessionId=e80df6de9008af772cfb48a389465415
&locale=en_US
&currencyCode=USD
&xml=<HotelRoomReservationRequest>
<hotelId>106347</hotelId>
<arrivalDate>10/30/2015</arrivalDate>
<departureDate>11/1/2015</departureDate>
<supplierType>E</supplierType>
<rateKey>469e1aff-49de-4944-a64d-25d96ccde3aa</rateKey>
<rateCode>200706716</rateCode>
<roomTypeCode>200127420</roomTypeCode>
<chargeableRate>252.00</chargeableRate>
<RoomGroup>
    <Room>
        <numberOfAdults>2</numberOfAdults>
        <numberOfChildren>2</numberOfChildren>
        <childAges>3,7</childAges>
        <firstName>test</firstName>
        <lastName>test</lastName>
        <smokingPreference>NS</smokingPreference>
        <bedTypeId>23</bedTypeId>
    </Room>
</RoomGroup>
<ReservationInfo>
    <email>test@travelnow.com</email>
    <firstName>test</firstName>
    <lastName>test</lastName>
    <homePhone>2145370159</homePhone>
    <workPhone>2145370159</workPhone>
    <creditCardType>CA</creditCardType>
    <creditCardNumber>5401999999999999</creditCardNumber>
    <creditCardExpirationMonth>04</creditCardExpirationMonth>
    <creditCardExpirationYear>2017</creditCardExpirationYear>
    <creditCardIdentifier>123</creditCardIdentifier>
</ReservationInfo>
<AddressInfo>
    <address1>travelnow</address1>
    <city>Seattle</city>
    <stateProvinceCode>WA</stateProvinceCode>
    <countryCode>US</countryCode>
    <postalCode>98117</postalCode>
</AddressInfo>
</HotelRoomReservationRequest>

I am using that code

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$header[] = "Accept: application/json";
        $header[] = "Accept-Encoding: gzip";
        $header[] = "Content-length: 0";


        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_ENCODING, "gzip");
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_VERBOSE, true);
        $verbose = fopen('php://temp', 'rw+');
        curl_setopt($ch, CURLOPT_STDERR, $verbose);

        $result = curl_exec($ch);


echo '<pre>';
print_r($result);

Please help me how i can post this data through curl to get the response.I am using this in wordpress for payment booking.

Related posts

1 comment

  1. Summarizing from the comments I posted:

    • If you’re trying to send data to the curl url, you need to use
      CURLOPT_POSTFIELDS
    • For header Content-length the 0 value may
      be an issue
    • To see if you are actually connecting to the URL (for
      example do you need to pass a username, password for
      authentication) you may want to echo out the returned headers with
      CURLOPT_HEADER
    • Your URL seems to be a GET Request with name/value pairs, but you are calling curl as a POST
    • A really good reference is at PHP.net http://php.net/manual/en/function.curl-setopt.php

Comments are closed.