接入教程
1. 阅读Amadeus授权指南获取访问令牌
2. 调用API端点并传入查询参数
3. 处理返回的酒店名称建议列表
4. 根据需求选择并验证酒店信息
5. 集成到您的应用程序中
Python请求示例
python
import requests
url = "https://api.example.com/v1/reference-data/locations/hotel"
params = {
"keyword": "Hilton",
"subType": "HOTEL_GDS"
}
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, params=params, headers=headers)
data = response.json()
print(data)
PHP请求示例
php
<?php
$url = "https://api.example.com/v1/reference-data/locations/hotel";
$params = [
"keyword" => "Hilton",
"subType" => "HOTEL_GDS"
];
$headers = [
"Authorization: Bearer YOUR_API_KEY"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
?>
JavaScript请求示例
javascript
const url = "https://api.example.com/v1/reference-data/locations/hotel";
const params = new URLSearchParams({
keyword: "Hilton",
subType: "HOTEL_GDS"
});
fetch(`${url}?${params}`, {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY"
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
常见问题
如何获取API访问令牌?
请参考Amadeus官方授权指南,通过OAuth 2.0客户端凭证流程获取访问令牌。测试环境需使用测试API密钥。
测试环境和生产环境有什么区别?
测试环境基于生产数据的子集,主要用于开发和集成测试,可能存在数据量限制和响应延迟。
支持哪些搜索参数?
主要支持关键词搜索和酒店类型筛选,具体参数请参考API文档中的请求参数说明。
Aitishiku.com