获取Expedia的酒店和房间图片列表

时间:2013-05-02 13:34:38

标签: asp.net api

使用Asp.Net我想从Expedia获得酒店和所有相应的属性,如酒店和房间图片。

它为所有属性提供了期望的图像。我想通过酒店列表服务获取酒店和房间图片。我该怎么做才能实现这个目标?这是我的要求

var serviceClient = new HotelServicesClient("ExpediaServicePort");

            var serviceRequest = new HotelListRequest();
            serviceRequest.apiKey = _apiKey;
            serviceRequest.locale = _culture == "tr" ? LocaleType.tr_TR : LocaleType.en_US;
            serviceRequest.localeSpecified = true;
            serviceRequest.currencyCode = _culture == "tr" ? "TRY" : "EUR";
            serviceRequest.supplierType = "E";
            serviceRequest.searchRadius = 100;
            serviceRequest.searchRadiusSpecified = true;
            serviceRequest.searchRadiusUnit = SearchRadiusUnitType.KM;
            serviceRequest.searchRadiusUnitSpecified = true;
            serviceRequest.arrivalDate = hotelListRequest.ArrivalAt.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
            serviceRequest.departureDate = hotelListRequest.DepartureAt.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
            serviceRequest.RoomGroup = new[] { new Room { numberOfAdults = hotelListRequest.AdultCount, numberOfChildren = hotelListRequest.ChildCount } };
            serviceRequest.sort = SortType.PRICE;
            serviceRequest.sortSpecified = true;
            serviceRequest.numberOfResults = 50;
            serviceRequest.numberOfResultsSpecified = true;

            if (hotelListRequest.Latitude.HasValue && hotelListRequest.Longitude.HasValue)
            {
                serviceRequest.latitude = (float)hotelListRequest.Latitude.Value;
                serviceRequest.latitudeSpecified = true;
                serviceRequest.longitude = (float)hotelListRequest.Longitude.Value;
                serviceRequest.longitudeSpecified = true;
            }
            else
            {
                serviceRequest.destinationString = hotelListRequest.City;
            }

            var hotelListResponse = new Entity.HotelList.HotelListResponse();

            var response = serviceClient.getList(serviceRequest);

            if (response.EanWsError != null)
                throw new Exception(response.EanWsError.verboseMessage);

            hotelListResponse.CacheKey = response.cacheKey;
            hotelListResponse.CacheLocation = response.cacheLocation;
            hotelListResponse.HasMore = response.moreResultsAvailable;

            if (true)
            {
                foreach (var serviceHotel in response.HotelList.HotelSummary)
                {
                    var hotel =

                        new Entity.Hotel
                            {
                                RefID = serviceHotel.hotelId,
                                Url = hotelUrl(serviceHotel.hotelId, _htmlDecodeFunc(serviceHotel.name)),  .......

1 个答案:

答案 0 :(得分:3)

LIST api不提供酒店图片,只提供缩略图。 有三个地方可以获得图像,INFO(酒店图像),ROOMIMAGES和AVAIL(房间图像)。

使用LIST(或任何api)提供的缩略图,您还可以通过替换最终的“_b”来获得各种格式。用'_l。' (景观), '_秒。' (小)或....这里列出了完全替换值: http://developer.ean.com/database_catalogs/relational/Image_Data https://support.ean.com/entries/21965722-Additional-Image-Sizes-Available

请记住,您在制作时仅限于40个请求/秒,因此获取LIST结果的所有图像会快速消耗掉。如果您使用的是其DB文件的本地版本,则可以从LIST获取所有图像,而无需ping其API。上面的第一个链接具有该文件的下载位置,只需要一些本地(无)SQL集成。