K
K
ken30132014-12-01 21:49:28
PHP
ken3013, 2014-12-01 21:49:28

How to get an object of a class?

There is a class, you need to get cacheKey from it . Tell me how to do it

class API extends Expedia
{

    public function getHotelList($params)
    {
        $result = array();

        try {
            $hotels = $this->list($params);
      

            if ($hotels != null && isset($hotels['HotelList'])) {
                $this->_totalHotels = $hotels['HotelList']['@activePropertyCount'];
            }
      
            while ($hotels != null) {
                if (isset($hotels['HotelList'])) {
                    if ($hotels['HotelList']['@size'] > 1) {
                        $result = array_merge($result, $hotels['HotelList']['HotelSummary']);
                    } else {
                        $result = array_merge($result, array($hotels['HotelList']['HotelSummary']));
                    }
                }
        
                if (!$hotels['moreResultsAvailable']) {
                    break;
                }

                if (isset($params['numberOfResults']) && count($result) <= intval($params['numberOfResults'])) {
                    break;
                }

                $hotels = $this->list(array(
                    'cacheKey' => $hotels['cacheKey'],
                    'cacheLocation' => $hotels['cacheLocation']
                ));
        
            }
        } catch (Exception $ex) {
            $data = $ex->getData();
            if ($data['category'] != 'RESULT_NULL') {
                throw new Exception($data);
            }
        }

        $this->_availableHotels = count($result);

        return $result;
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Evgrafovich, 2014-12-01
@Tantacula

habrahabr.ru/post/197332 study. See where $bar is in the example, this is your $hotels. Getters and setters, in theory, are not necessarily to be used, it was just lazy to write code :)

K
ken3013, 2014-12-02
@ken3013

Thanks for the answer. I'll try to solve the problem. If you have a desire, then write to me at [email protected], there is a task that needs to be completed =) Budget 2
thousand rubles There is an API tour. Agencies - developer.ean.com/docs
There is an implementation in PHP - https: //github.com/dyatlov/Expedia-PHP-API
It is necessary to do:
1. Pagination of hotels (Now everything is on one page);
2. Search for hotels by name;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question