我正在使用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');
我喜欢我说我一无所获。我检查了所有的代码,我没有看到问题,网址是正确的..任何帮助将非常感激。提前谢谢。
答案 0 :(得分:2)
客户IP地址为10.184.2.9
,您说?我对此持怀疑态度。
在curl_exec
之后,但在您关闭$ch
之前,立即回显curl_error($ch)
的输出。那里有什么用处吗?