简体   繁体   中英

onsite booking for expedia by rest api calling using curl post

Onsite booking process now i am using rest api calling to get the data about booking process.But now the problem is that when I set the form url is :-

$url = '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
&hotelId=106347
&arrivalDate=10/30/2015
&departureDate=11/01/2015
&supplierType=E
&rateKey=469e1aff-49de-4944-a64d-25d96ccde3aa
&roomTypeCode=200127420
&rateCode=200706716
&chargeableRate=257.20
&room1=2,5,7
&room1FirstName=test
&room1LastName=testers
&room1BedTypeId=23
&room1SmokingPreference=NS
&email=test@yourSite.com
&firstName=tester
&lastName=testing
&homePhone=2145370159
&workPhone=2145370159
&creditCardType=CA
&creditCardNumber=5401999999999999
&creditCardIdentifier=123
&creditCardExpirationMonth=11
&creditCardExpirationYear=2015
&address1=travelnow
&city=Bellevue
&stateProvinceCode=WA
&countryCode=US
&postalCode=98004';

and when i manually posted the data it will get the response But when I am using curl to post the url which i have posted previous it will face the error. My curl code is :-

$header[] = "Accept: application/json";
$header[] = "Accept-Encoding: gzip";
$header[] = "Content-length: 0";
$ch = curl_init();

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
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);

After posting data i will get the response

{"HotelRoomReservationResponse":{"EanWsError":{"itineraryId":-1,"handling":"UNRECOVERABLE","category":"EXCEPTION","exceptionConditionId":-1,"presentationMessage":"TravelNow.com cannot service this request.","verboseMessage":"Exception Caught: null"},"customerSessionId":"8ab1d482-f968-49d2-a429-a1cbab748fe5"}}

So i will get that error repeatedly. Please help me how i can find the right data.

Your problem here is that you are parsing the parameters in the url they need to be given in the body see thetop of this page: http://developer.ean.com/docs/book-reservation/examples/rest-reservation/

Not sure how you do this in PHP but you can use -d on the command line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM