設定
本文說明如何快速以開發者身份設定並開始在 Wink 上測試我們的 API。
請依照以下步驟操作:
- 在 Wink 上 註冊 您的使用者帳號
- 建立 旅行社帳號 或 旅行社帳號 。
- 建立應用程式 ,並將其與步驟 2 中建立的帳號關聯。
- 建立
Application後,請妥善保存 client-id 和 client secret。
在 Wink,我們使用 Cloudinary 管理所有圖片和影片資產。當您存取我們的旅遊庫存時,將可完整使用 Cloudinary 的所有進階功能。
我們的 cloud_name 是 traveliko。
Cloudinary
Section titled “Cloudinary”對於我們支援的每種旅遊庫存類型,都會有一個名為 multimedias 的巢狀 JSON 陣列。多媒體項目的 JSON 範例如下:
{ "multimediaIdentifier": "multimedia-1", "identifier": "partners/radisson_blu_logo", "type": "IMAGE", "width": "1024", "height": "768", "category": "1", "descriptions": [ { "name": "Lobby", "description": "Picture of the lobby", "language": "en" } ], "lifestyleType": "LIFESTYLE_BUSINESS", "attribution": [ { "url": "https://www.hilton.com", "name": "Hilton" } ]}上方標示的行顯示了 Cloudinary 的唯一 ID partners/radisson_blu_logo。您只需此 ID 即可取得任何格式、品質與尺寸的圖片。
請前往我們的 API 區域,選擇您想使用的 API。
API 文件
Section titled “API 文件”我們的文件網站設計可讓您直接在網站內執行 API 指令。
此範例中,您將使用 Search Lookups (OAuth2) API 呼叫。
- 使用 Lookup API 取得目的地或飯店資料。
- 在左側導覽列點選
Authentication。 - 輸入您的 client-id 和 client secret,然後點擊
Get TOKEN按鈕。 - 若憑證有效,您將看到 API 金鑰已套用。
- 現在即可測試 lookup 端點。
Postman
Section titled “Postman”您也可以使用 Postman 進行相同操作。
- 下載 Postman 。
- 在 Lookup API 頁面頂端點選
Download OpenAPI spec。 - 將其匯入 Postman。
- 若匯入為名為
Wink API的新集合,點擊集合名稱旁的橫向省略符號(三點),選擇Edit。 - 在
Authorization標籤中,將Auth type設為 OAuth2。 - 將
Add auth data to設為Request headers。 - 將
Header prefix設為Bearer。 - 將
Token Name設為您想在 Postman 中儲存的名稱,例如 Wink Staging。 - 將
Grant type設為Client Credentials。 - 將
Access token URL設為 https://staging-iam.wink.travel/oauth2/token。 - 將
Client ID設為您的應用程式所產生的 Client ID。 - 將
Client Secret設為您的應用程式所產生的 Client Secret。 - 將
Scope設為inventory.read inventory.write inventory.remove。這些是 Wink 所需的所有權限範圍。 - 將
Client Authentication設為Send as Basic Auth header。 - 點擊
Get New Access Token按鈕以取得並儲存您的存取權杖。 - 在 Wink API 集合下的所有 API 呼叫中,確保認證標籤顯示
Inherit auth from parent,以便每次呼叫都包含您的權杖。