此為系統自動產生的翻譯

旅宿 ID 搜尋

此範例示範如何透過「住宿列表 API」,使用 Expedia 旅宿識別碼來擷取住宿內容及價格資訊。

旅宿的 ID 搜尋所需的搜尋條件比 location-based 的搜尋更少,因此在取得旅宿的內容和價格方面更為高效。

有關如何擷取旅宿 ID 的詳細資訊,請參閱擷取旅宿靜態資料 如需有關 Listings API 的更多資訊,請參閱Listings API 文件

1. 使用 SDK 中定義的類別建立請求物件

GetLodgingListingsOperationParams getLodgingListingsOperationParams =
        GetLodgingListingsOperationParams.builder()
            .partnerTransactionId("PARTNER TRANSACTION ID")
            // Expedia Property IDs to search for
            .ecomHotelIds(new HashSet<>(Arrays.asList("73460112", "2330513")))
            // The links to return, WEB includes WS (Web Search Result Page)
            // and WD (Web Details Page)
            .links(Collections.singletonList(GetLodgingListingsOperationParams.Links.WEB))
            // Check-in 5 days from now
            .checkIn(LocalDate.now().plusDays(5))
            // Check-out 10 days from now
            .checkOut(LocalDate.now().plusDays(10))
            // Filter the properties that are available only
            .availOnly(true)
            // Use the default occupancy: 2 adults in one room
            .build();

GetLodgingListingsOperation getLodgingListingsOperation =
        new GetLodgingListingsOperation(getLodgingListingsOperationParams);

2. 使用服務客戶端進行 API 呼叫。

Response<HotelListingsResponse> hotelListingsResponse =
        client.execute(getLodgingListingsOperation);
這個頁面對您有幫助嗎?
我們能如何改善內容?
感謝您協助我們進行改善!