我不知道为什么,可能我只是愚蠢但我一直在尝试从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种组合一样,但根本没有输出。
我真的希望有人可以帮助我。
最诚挚的问候 托马斯
答案 0 :(得分:2)
看起来像是:$result['hotels']->HotelList->HotelSummary[0]->name;
但是obv。未经测试。