Expedia EAN / TravelNow搜索城市名称问题

时间:2013-08-12 05:10:39

标签: php xml api rest

我使用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”给出的city / destinationString没有列出任何酒店。我们也使用了API测试程序http://devhub.ean.com/apitester/index.html并收到了相同的结果。

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

让我们知道如何实施上述请求以正确列出特定城市的酒店。这仅适用于我们在搜索中列出的几个城市。下面显示的是伦敦我们用于传递请求的确切城市名称列表。如果城市名称不正确,那么他们需要如何纠正?

贝斯沃特-帕丁顿 Belgravia区, 布卢姆斯伯里 - 索霍区, 金丝雀码头 - 码头区, 卡姆登镇, 切尔西, 切尔西,骑士桥, 威斯敏斯特市, 唐人街, 东区, 富勒姆, 格林威治, 霍尔本, 哈默史密斯, 汉普斯特德, 汉普斯特德 - 卡姆登镇, 豪恩斯洛, 伊斯灵顿, 骑士桥, 肯辛顿, 兰贝斯, 伦敦, 伦敦地区, 菲儿, 伦敦梅费尔马里波恩, 马里波恩, 皮姆利科, 圣潘克拉斯 - 伊斯灵顿, 苏豪区, 萨瑟克 - 滑铁卢

请帮助处理适用于上述城市/城市的REST / XML请求字符串。

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

4 个答案:

答案 0 :(得分: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>";

您需要更多详细信息。 见links

答案 1 :(得分:1)

您必须使用api测试人员提供的geoSearch标签:ean:

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'];

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

答案 2 :(得分: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/

答案 3 :(得分:0)

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

function prepare_xml($xml=""){
    $xml = preg_replace('/\s+/', ' ',$xml);
    $xml = str_replace("> <","><",$xml);
    return $xml;
}
相关问题