เริ่มต้นอย่างรวดเร็ว
ในหน้านี้คุณจะได้รับโทเค็นด้วยข้อมูลรับรองของพาร์ทเนอร์ และส่งคำขอค้นหาห้องพักและราคา สิ่งที่ต้องมีคือ apiKey, apiSecret และ ID ของโรงแรมใน HMS (hotelID) หากยังไม่มี โปรดติดต่อฝ่ายสนับสนุน
1. รับโทเค็น#
เอนด์พอยต์เข้าสู่ระบบรับฟิลด์แบบฟอร์ม และไม่ต้องใช้เฮดเดอร์ยืนยันตัวตน:
curl "https://test.hms.gen.tr/external/public/login" \
-d "apiKey=$HMS_API_KEY" \
-d "apiSecret=$HMS_API_SECRET" \
-d "hotelCode=1000"{
"success": true,
"hotelCode": "1000",
"token": "eyJlbmREYXRlIjp7ImRhdGUiOiIyMDI2LTA5LTE1IDEwOjI0OjMxLjAwMDAwMCIs…",
"hotelSeoUrl": "demo-otel"
}เก็บ token ไว้ เพราะจะใช้ในทุกคำขอสำหรับโรงแรมนี้เป็นเวลา 7 วัน
export HMS_TOKEN="eyJlbmREYXRlIjp7ImRhdGUiOiIyMDI2LTA5LTE1IDEwOjI0OjMxLjAwMDAwMCIs…"2. ค้นหาห้องพักและราคา#
ตัวอย่างการค้นหาสำหรับผู้ใหญ่สองคน สองคืน:
curl "https://test.hms.gen.tr/external/online/roomType" \
-H "Authorization: Bearer $HMS_TOKEN" \
-d "hotelID=1000" \
-d "startDate=2026-08-18" \
-d "endDate=2026-08-20" \
-d "adultCount=2" \
-d "language=en"const res = await fetch("https://test.hms.gen.tr/external/online/roomType", {
method: "POST",
headers: { "Authorization": `Bearer ${process.env.HMS_TOKEN}` },
body: new URLSearchParams({
hotelID: "1000",
startDate: "2026-08-18",
endDate: "2026-08-20",
adultCount: "2",
language: "en"
})
});
const data = await res.json();
if (!data.success) throw new Error(`${data.errorCode}: ${data.errorMessage}`);
for (const room of data.items) {
console.log(room.name, room.roomCount, "rooms");
}$ch = curl_init('https://test.hms.gen.tr/external/online/roomType');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('HMS_TOKEN')],
CURLOPT_POSTFIELDS => http_build_query([
'hotelID' => 1000,
'startDate' => '2026-08-18',
'endDate' => '2026-08-20',
'adultCount' => 2,
'language' => 'en',
]),
]);
$data = json_decode(curl_exec($ch), true);
if (empty($data['success'])) {
throw new RuntimeException($data['errorCode'] . ': ' . $data['errorMessage']);
}
foreach ($data['items'] as $room) {
echo $room['name'], ' · ', $room['roomCount'], " rooms\n";
}3. อ่านการตอบกลับ#
ประเภทห้องพักแต่ละรายการมีแผนอาหาร (accommodationTypes) และแผนอาหารแต่ละรายการมีตัวเลือกราคา (prices) ตัวอย่างแบบตัดทอน:
{
"success": true,
"items": [
{
"id": 2,
"name": "Standard Room",
"roomCount": 5,
"currency": "TRY",
"accommodationTypes": [
{
"id": 2,
"title": "Bed & Breakfast",
"priceType": 0,
"prices": {
"2-1": {
"total": 2,
"price": "1930.00",
"currency": "TRY",
"nonRefundable": "",
"id": "2/2"
},
"2-0": {
"total": 2,
"price": "1737.00",
"currency": "TRY",
"nonRefundable": "[NR]",
"id": "2-0/2"
}
}
}
]
}
],
"count": 1
}2-1: 2 คน ราคามาตรฐาน (คืนเงินได้)2-0: 2 คน ราคาแบบไม่คืนเงิน (nonRefundable: "[NR]")priceคือยอดรวมของการเข้าพักทั้งหมด ส่วนtotalคือจำนวนคืน ราคารายคืนอยู่ในอาร์เรย์prices[]ของการตอบกลับฉบับเต็ม- ในการจอง ให้ส่ง
idของประเภทห้องพักเป็นroomTypeIDและidของแผนอาหารเป็นratePlanID
ขั้นตอนต่อไป#
- ขั้นตอนการจอง — ตั้งแต่การเลือกห้องไปจนถึงการส่ง
BookingPushRQ - ขั้นตอนการชำระเงิน — ชำระที่โรงแรม โอนเงินผ่านธนาคาร บัตรเครดิต ชำระเงินออนไลน์
- รหัสข้อผิดพลาด — ค่าของ
errorCodeและmessage