我不知道为什么,可能我只是愚蠢,但我已经尝试从 Expedia API 请求中提取内容超过 2 小时了。可能我今天在这个网站上工作了很长时间,所以我看不到一个简单的错误,但无论如何我没有找到它。API 请求“HotelList”对我造成了这个问题,获取 HotelDetails 并从返回的 XML 输出中提取数据工作得很好,并且在第一次尝试时工作得很好。
我的请求得到的请求/结果如下所示:
$result = $search->getHotels($dataArray);
--------------------------------------------
RESULT (print_r) LOOKS LIKE THIS
Array
(
[current_search] => Array
(
[check_in] => 05/08/2013
[check_out] => 05/13/2013
)
[title] =>
[hotels] => SimpleXMLElement Object
(
[customerSessionId] => XXXXXXXXXXXXX
[numberOfRoomsRequested] => 1
[moreResultsAvailable] => true
[cacheKey] => XXXXXXXXXXXXXXXXX
[cacheLocation] => XXXXXXXXXXXXXX
[cachedSupplierResponse] => SimpleXMLElement Object
(
[@attributes] => Array
(
[matchedLocale] => true
[matchedCurrency] => true
[tpidUsed] => 5102
[otherOverheadTime] => 5
[candidatePreptime] => 62
[supplierResponseTime] => 1950
[supplierResponseNum] => 5
[supplierRequestNum] => 513
[cachedTime] => 0
[supplierCacheTolerance] => NOT_SUPPORTED
)
)
[HotelList] => SimpleXMLElement Object
(
[@attributes] => Array
(
[activePropertyCount] => 562
[size] => 5
)
[HotelSummary] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[ubsScore] => 2147483647
[order] => 0
)
[hotelId] => 126913
[name] => The New Yorker Hotel
[address1] => 481 Eighth Ave.
[city] => New York
[stateProvinceCode] => NY
我一直在尽一切努力获得这家酒店的名称,但我什至无法提取 check_in 返回结果或类似的东西。我只是在尝试这样的东西:
echo $result->hotels->HotelList->HotelSummary[0]->name;
echo $result->HotelList->HotelSummary[0]->name;
echo $result->$HotelSummary[0]->name; or
echo $result->current_search->check_in;
可能像其他 20 种组合一样,但根本没有输出。
我真的希望有人可以在这里帮助我。
最好的问候托马斯