我正在尝试设置hotelbeds API。 现在我得到了我期望的结果,直到我试图应用过滤器:
$rqData->destination = new Destination("PAR");
$occupancy = new Occupancy();
$occupancy->adults = 2;
$occupancy->children = 1;
$occupancy->rooms = 1;
$occupancy->paxes = [ new Pax(Pax::AD, 30, "Mike", "Doe"),
new Pax(Pax::AD, 27, "Jane", "Doe"),
new Pax(Pax::CH, 8, "Mack", "Doe")
];
$rqData->occupancies = [ $occupancy ];
$filter = new Filter();
$filter->zone = 64 ;
$rqData->filter = [ $filter ];
$availRS = $apiClient->availability($rqData);
if ($availRS->isEmpty()) {
echo "There are no results!";
}
$allResponse = $availRS->hotels->toArray();
如您所见,我将过滤器设置为zone 64
,这会出现以下错误:
致命错误:未捕获异常'异常',消息'类型错误:字段过滤器需要hotelbeds \ hotel_api_sdk \ model \过滤器类型!'在C:\ xampp2 \ htdocs \ hotelbeds \ src \ generic \ DataContainer.php:58堆栈跟踪:#0 C:\ xampp2 \ htdocs \ hotelbeds \ test.php(110):hotelbeds \ hotel_api_sdk \ generic \ DataContainer-> __ set('filter',Array)#1 {main}抛出C:\ xampp2 \ htdocs \ hotelbeds \第58行的src \ generic \ DataContainer.php
我确实将zone
作为整数添加到过滤类中。
我从测试函数http://testapi.hotelbeds.com/search得到了这个过滤器 - >请求
{
"stay": {
"checkIn": "2017-05-08",
"checkOut": "2017-05-12",
"shiftDays": 2
},
"occupancies": [
{
"rooms": 1,
"adults": "2",
"children": "0",
"paxes": [
{
"type": "AD",
"age": "30"
},
{
"type": "AD",
"age": "30"
}
]
}
],
"filter": {
"maxHotels": 20,
"maxRooms": 4,
"maxRatesPerRoom": 3,
"minCategory": 1,
"maxCategory": 5,
"paymentType": "BOTH",
"maxRate": "3000"
},
"destination": {
"code": "PAR",
"zone": "64"
}
}
如果有人能告诉我我做错了什么会很棒。
提前致谢!