1

我已经使用 XML 和 PHP 实现了 EAN 酒店搜索 API。在搜索和列出酒店时,我遇到了以下问题。

搜索详情

City - Soho
Country - GB
Arrival - Aug 1, 2013
Departure - Aug 2, 2013
Rooms - 1 room with 2 adults

TravelNow 网站中的结果

http://www.travelnow.com/templates/331656/hotels/list?lang=en&currency=GBP&secureUrlFromDataBridge=https%3A%2F%2Fwww.travelnow.com&requestVersion=V2&destination=&standardCheckin=8%2F1%2F2013&standardCheckout=8%2F2%2F2013&checkin=8%2F1%2F13& amp;checkout=8%2F2%2F13&rating=0&targetId=AREA-d5cfc783-9e42-4440-9200-0bd17397c37f%7Clandmarks&roomsCount=1&rooms[0].adultsCount=2&rooms[0].childrenCount=0&filter.sortedBy=our_rec&filter.hotelName=&filter.lowPrice=0&filter.travelerOpinion=0&filter.breakfastIncluded=false&subscriptionInfo.termsConditionAgreement=false&subscriptionInfo.wantNews=false&subscriptionInfo.wantNewsletters=false&tab=list

在 TravelNow 网站中,我们搜索了英国伦敦的 Soho,如上图所示

已发送请求

http://api.ean.com/ean-services/rs/hotel/v3/list?currencyCode=GBP&minorRev=99&apiKey=XXXXXXXXXXXXXXXXXXXXXXXX&locale=en_US&cid=XXXXXXXX&sort=OVERALL_VALUE&xml=<HotelListRequest><city>Soho<%2Fcity><countryCode>GB<%2FcountryCode><arrivalDate>08%2F01%2F2013<%2FarrivalDat e><departureDate>08%2F02%2F2013<%2FdepartureDate><numberOfResults>25<%2FnumberOfResults><supplierType>E%7CV<%2FsupplierType><supplierCacheTolerance>MED_ENHANCED<%2FsupplierCacheTolerance><RoomGroup><Room><numberOfAdults>2<%2FnumberOfAdults><%2FRoom><%2FRoomGroup><%2FHotelListRequest>

收到回复

<ns2:HotelListResponse xmlns:ns2="http://v3.hotel.wsapi.ean.com/">
<EanWsError>
<itineraryId>-1</itineraryId>
<handling>UNKNOWN</handling>
<category>EXCEPTION</category>
<exceptionConditionId>-1</exceptionConditionId>
<presentationMessage>No Results Available</presentationMessage>
<verboseMessage>Result was null</verboseMessage>
<ServerInfo serverTime="05:45:17.821-0500" timestamp="1375181117" instance="54"/>
</EanWsError>
<customerSessionId>0ABAAA36-B023-AF91-4022-F2DA5EE95A74</customerSessionId>
</ns2:HotelListResponse>

我还搜索了城市/目的地字符串中的城市字符串“Soho, London, United Kingdom”,没有列出任何酒店。我们也使用了 API 测试器http://devhub.ean.com/apitester/index.html并收到了相同的结果。

此搜索大多显示伦敦的许多城市都没有结果。我们尝试了http://developer.ean.com/docs/read/hotel_list/examples/XML_Alternatives中显示的基于“destinationString”的搜索,但也没有成功。我们需要如何通过目的地/城市?即使它显示酒店,它们也不在给定城市内/周围。

让我们知道如何实现上述请求以正常工作以列出给定城市的酒店。这仅适用于我们在搜索中列出的少数城市。下面显示的是伦敦的确切城市名称列表,我们用于在块内传递请求。如果以下城市名称不正确,那么需要如何更正?

Bayswater-Paddington, Belgravia, Bloomsbury-Soho, Canary Wharf-Docklands, Camden Town, Chelsea, Chelsea-Knightsbridge, City of Westminster, 唐人街, East End, Fulham, Greenwich, Holborn, Hammersmith, Hampstead, Hampstead-Camden Town, Hounslow, Islington, Knightsbridge, Kensington, Lambeth, London, London area, Mayfair, Mayfair-Marylebone, Marylebone, Pimlico, St. Pancras - Islington, Soho, Southwark-Waterloo

请提供适用于上述城市的 REST/XML 请求字符串。

我还没有接受任何当前的答案,但正在寻找更正确的答案来敲响警钟。

4

4 回答 4

1

您必须使用 ean 在 api tester 提供的 geoSearch 选项卡:

http://devhub.ean.com/apitester/index.html

之后,您必须在其中插入目标字符串并根据响应获取城市名称。这是您必须如何执行此操作的示例代码:

$destination="soho";//YOUR Destination string

$Geosearch='https://api.eancdn.com/ean-services/rs/hotel/v3/geoSearch?cid=50555&minorRev=99&apiKey=**XXXXX(your_api_key)**&locale=en_US&currencyCode=USD&xml=%3CLocationInfoRequest%3E%0A%20%20%20%20%3Clocale%3Een_US%3C%2Flocale%3E%0A%20%20%20%20%3CdestinationString%3E';
$Geosearch.=$destination;
$Geosearch.='%3C%2FdestinationString%3E%0A%3C%2FLocationInfoRequest%3E';

$locate = json_decode(file_get_contents($Geosearch),true);
$citynames=$locate['LocationInfoResponse']['LocationInfos']['LocationInfo'];
$citysearched=$citynames['city'];

现在您必须使用酒店列表 url 并连接$citysearched值而不是您的目标字符串。

于 2013-11-08T07:09:19.167 回答
1

我正在使用 REST 方法获取酒店列表

我的代码如下

$url = 'http://api.ean.com/ean-services/rs/hotel/v3/list?minorRev=14
&cid=55505
&apiKey=p9ycn9cxb2zp3k3gfvbf5aym
&customerUserAgent=&customerIpAddress=
&locale=en_US
&currencyCode=USD
&city=Lasvegas
&stateProvinceCode=NV
&countryCode=US
&supplierCacheTolerance=MED
&arrivalDate=08/25/2013
&departureDate=08/27/2013
&room1=2
&numberOfResults=25
&supplierCacheTolerance=MED_ENHANCED';

  $header[] = "Accept: application/json";
  $header[] = "Accept-Encoding: gzip";
  $ch = curl_init();
  curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
  curl_setopt($ch,CURLOPT_ENCODING , "gzip");
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  curl_setopt( $ch, CURLOPT_URL, $url );
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  $response = json_decode(curl_exec($ch));
  $rt =  curl_getinfo($ch);
  echo "<pre>";
  print_r($response);
  echo "</pre>";

你想要更多的细节。看到这个链接

于 2013-08-12T05:43:02.080 回答
0

您可以使用 file_get_contents

下面是代码

$request = "http://dev.api.ean.com/ean-services/rs/hotel/v3/list";
$minorRev = "20";
$cid = "55505";
$api = "p9ycn9cxb2zp3k3gfvbf5aym";

//room available
$response = file_get_contents($request . '?minorRev=' . $minorRev . '&cid=' . $cid . '&apiKey=' . $api . '&locale=en_US&currencyCode=MYR&hotelId='. $hotel_id . '&arrivalDate=' . $arrivalDate . '&departureDate=' . $departureDate .  $room . '&includeDetails=true&includeRoomImages=true&options=HOTEL_DETAILS,ROOM_TYPES,ROOM_AMENITIES,HOTEL_IMAGES');
$result = json_decode($response, false);

顺便说一下api链接应该是http://dev.api.ean.com/

于 2014-06-24T09:32:31.043 回答
0

我遇到了同样的问题,最后发现了空格(\n \r)的问题。您可以使用以下方法删除空格。

function prepare_xml($xml=""){
    $xml = preg_replace('/\s+/', ' ',$xml);
    $xml = str_replace("> <","><",$xml);
    return $xml;
}
于 2014-07-02T11:57:55.650 回答