身份验证

访问 Online Booking API 需使用 HMS 签发的合作伙伴凭据。登录端点用 apiKeyapiSecret 换取 token,之后的所有请求都在 Authorization: Bearer 请求头中携带该 token。详见身份验证指南。

登录并获取 token#

POST/external/public/login

无需身份验证 · 请求体: application/x-www-form-urlencodedmultipart/form-data

验证合作伙伴凭据;若合作伙伴已获得该酒店的授权,则签发 token。token 绑定单个酒店;对接多家酒店时需分别登录。

表单字段

apiKeystring必填
HMS 签发的合作伙伴密钥。
apiSecretstring必填
合作伙伴机密密钥,只能保存在服务端。
hotelCodeinteger必填
酒店在 HMS 中的 ID(hotelID)。合作伙伴必须已获得该酒店的授权。
hotelSeoUrlstring
酒店在 HMS 中的 SEO 别名。仅 HMS 自有的预订引擎用它代替 hotelCode;第三方集成请发送 hotelCode

响应

200 token 与酒店信息。token 有效期为 7 天;请在过期前重新登录以续期。

successboolean
结果标志。
hotelCodestring
token 所绑定的酒店 ID。
tokenstring
Bearer token。请将其视为不透明字符串,不要解析。
hotelSeoUrlstring | null
酒店的 SEO 别名。

错误响应

  • 200 partner_is_not_found — 密钥对不匹配;hotel_is_not_found — 找不到与 hotelSeoUrl 对应的酒店;hotel_permission_is_not_found — 合作伙伴未获得该酒店的授权,或授权已停用。
请求
curl "https://test.hms.gen.tr/external/public/login" \
  -d "apiKey=5y94tLmALIKDyUVdEPlAAjg5xWGQNgQtnALlV4+Am7Q=" \
  -d "apiSecret=a143d6408634696b811def06d236682950cacb9761aa8ad5827da4015bda4b19" \
  -d "hotelCode=1000"
响应 · 200
{
    "success": true,
    "hotelCode": "1000",
    "token": "eyJlbmREYXRlIjp7ImRhdGUiOiIyMDI2LTA5LTE1IDEwOjI0OjMxLjAwMDAwMCIsInRpbWV6b25lX3R5cGUiOjMsInRpbWV6b25lIjoiRXVyb3BlL0lzdGFuYnVsIn0sInRva2VuIjoiM2tkOXNscTJwbTh2eHI0dHp5Nm53YjFoYzdmajVnYTAiLCJob3RlbElEIjoxMDAwLCJ1c2VySUQiOjQyLCJkYXRlIjp7ImRhdGUiOiIyMDI2LTA5LTA4IDEwOjI0OjMxLjAwMDAwMCJ9fQ==",
    "hotelSeoUrl": "demo-otel"
}
响应 · 200(失败)
{
    "success": false,
    "token": null,
    "message": "hotel_permission_is_not_found"
}
最后更新: 2026年9月21日发现错误?请告诉我们