2

使用 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)),  .......
4

1 回答 1

3

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

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

请记住,您在生产中被限制为每秒 40 个请求,因此获取 LIST 结果的所有图像会很快消耗掉它。如果您使用他们的数据库文件的本地版本,您可以从列表中获取所有图像,而无需 ping 他们的 API。上面的第一个链接包含该文件的下载位置,只需要一些本地(无)SQL 集成。

于 2013-06-24T14:19:33.687 回答