我正在使用Expedia的api,我正在尝试进行测试预订。我必须调用一个https网址。我已经能够连接到所有其他正常的http请求,但现在我被卡住了。这是我如何调用页面。我的表单中的所有 PHP 值都是正确的,但我在 XML 文件中什么也没得到。我的意思是没有错误,什么都没有!我真的被困住了,不知道该怎么办。这是我的 php 代码:
$ch = curl_init();
$fp = fopen('bookit.xml','w');
curl_setopt($ch, CURLOPT_URL, "https://book.api.ean.com/ean-services/rs/hotel/v3/res?cid=55505&minorRev=13&apiKey=4sr8d8bsn75tpcuja6ypx5g3&locale=en_US¤cyCode=USD&customerIpAddress=10.184.2.9&customerUserAgent=Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/535.11+(KHTML,+like+Gecko)+Chrome/17.0.963.79+Safari/535.11&customerSessionId=&locale=en_US¤cyCode=USD&xml=<HotelRoomReservationRequest><hotelId>".$hid."</hotelId><arrivalDate>".$arrive."</arrivalDate><departureDate>".$depart."</departureDate><supplierType>".$supplier."</supplierType><rateKey>".$rkey."</rateKey><rateCode>".$ratecode."</rateCode><roomTypeCode>".$roomcode."</roomTypeCode><chargeableRate>".$total."</chargeableRate><RoomGroup><Room><numberOfAdults>".$adults."</numberOfAdults><numberOfChildren>".$children."</numberOfChildren><childAges>".$childages."</childAges><firstName>".$fname."</firstName><lastName>".$lname."</lastName><smokingPreference>".$smoking."</smokingPreference></Room></RoomGroup><ReservationInfo><email>".$email."</email><firstName>".$ccname."</firstName><lastName>".$cclast."</lastName><homePhone>".$phone."</homePhone><workPhone></workPhone><creditCardType>".$cc."</creditCardType><creditCardNumber>".$ccnumber."</creditCardNumber><creditCardExpirationMonth>".$exmonth."</creditCardExpirationMonth><creditCardExpirationYear>".$exyear."</creditCardExpirationYear><creditCardIdentifier>".$ccsecure."</creditCardIdentifier></ReservationInfo><AddressInfo><address1>".$street1."</address1><city>".$city."</city><stateProvinceCode>AZ</stateProvinceCode><countryCode>".$country."</countryCode><postalCode>".$zip."</postalCode></AddressInfo></HotelRoomReservationRequest>");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
$val = curl_exec($ch);
curl_close($ch);//Close curl session
fclose($fp); //Close file overwrite
var_dump($val);
$data = simplexml_load_file('bookit.xml');
我喜欢我说我什么也没得到。我已经检查了所有代码,我没有看到问题,网址是正确的。任何帮助将不胜感激。提前谢谢。
客户 IP 地址是10.184.2.9
,你说?我对此持怀疑态度。
紧接在curl_exec
之后,但在关闭$ch
之前,回显curl_error($ch)
的输出。那里有什么有用的吗?