Made the API response to Tripadvisor

$this->load->library(‘gapitripadvisor/gapitripadvisor’);
$endpoint = ‘api/tripadvisor2/search’;
$request_params = array();
$request_params[‘city_id’] = ‘47292’;
$request_params[‘check_in’] = $check_in;
$request_params[‘check_out’] = $check_out;
$request_params[‘search_type’] = ‘city’;
$request_params[‘num_rooms’] = $room_count;
$request_params[‘guests’] = $room_pax_str;
$request_params[‘guests_count’] = $pax;
$request_params[‘base_url’] = BASE_URL;
$request_params[‘domain_id’] = !empty($domain_result->domain_id) ? $domain_result->domain_id : ”;

//echo ‘<pre>’; print_r($request_params);
$response = $this->gapitripadvisor->send_request(‘GET’, $endpoint, $request_params);

 

// headers to tell that result is JSON

header(‘Content-type: application/json’);

//echo $response;

 

$trip = json_decode($response,true);

//print_r($trip);die;

$trip_hotels = $trip[‘results’][‘hotels’];

//print_r($trip_hotels);die;

foreach($trip_hotels as $hotels)

{

//print_r($hotels);die;

$hotel[‘hotel_id’] = $hotels[‘hotel_id’];

$hotel[‘hotel_code’] = $hotels[‘hotel_code’];

$hotel[‘room_type’] = $hotels[‘room_type’];

$hotel[‘name’] = $hotels[‘name’];

$hotel[‘api’] = $hotels[‘api’];

$hotel[‘resort_fee’] = $hotels[‘resort_fee’];

 

$hotel[‘price’][‘price_per_room_per_night’] = $hotels[‘price’][‘price_per_room_per_night’];

$hotel[‘price’][‘tax_percentage’] = $hotels[‘price’][‘tax_percentage’];

$hotel[‘price’][‘sub_total’] = $hotels[‘price’][‘sub_total’];

$hotel[‘price’][‘tax_amount’] = $hotels[‘price’][‘tax_amount’];

$hotel[‘price’][‘total_price’] = $hotels[‘price’][‘total_price’];

$hotel[‘price’][‘currency_code’] = $hotels[‘price’][‘currency_code’];

 

$hotel[‘language’] = $hotels[‘language’];

$hotel[‘url’] = $hotels[‘url’];

$hotel_response = $hotel;

//}

//echo “=====>”.print_r($hotel_response);die;

$trip_result = [

“api_version”=> 8,

“language”=> “en_US”,

“availability_request”=> [

“api_version”=> 8,

“start_date”=> “2017-05-01”,

“end_date”=> “2017-05-03”,

“party”=> [[

“adults”=> 3

],

[

“adults”=> 2,

“children”=> [

9,

5

]

]],

“language”=> “en_US”,

“query_key”=> “6167a22d1f87d2028bf60a8e5e27afa7_191_1360299600000_2_2”,

“currency”=> “USD”,

“user_country”=> “US”,

“device_type”=> “Desktop”,

“availability_id”=> “a2fd740a-ad02-476d-b314-925a125509be”,

“requested_payload”=> [

“categories”=> [

“room_type_details”=> false,

“rate_plan_details”=> false,

“room_rate_details”=> false,

“hotel_details”=> false

],

“category_modifiers”=> [

“partner_booking_data”=> false,

“real_time_pricing”=> false,

“multiple_room_rates”=> false,

“photos”=> false,

“text”=> false

]

],

“hotels”=> [

[

“ta_hotel_id”=> $hotel_response[‘hotel_id’],

“partner_hotel_code”=> $hotel_response[‘hotel_code’]

],

]],

“response_payload”=> [

“categories”=> [

“room_type_details”=> false,

“rate_plan_details”=> false,

“room_rate_details”=> false,

“hotel_details”=> false

],

“category_modifiers”=> [

“partner_booking_data”=> false,

“real_time_pricing”=> false,

“multiple_room_rates”=> false,

“photos”=> false,

“text”=> false

]

],

 

 

“hotels”=> [

“A123″=> [

“response_type”=> “available”,

“available”=> [

“room_types”=> [

“1”=> [

“persistent_room_type_code”=> $hotel_response[‘room_type’]

],

],

“rate_plans”=> [

“1”=> [

“persistent_rate_plan_code”=> “BR21”

],

“2”=> [

“persistent_rate_plan_code”=> “OL44”

]

],

“room_rates”=> [

“1”=> [

“persistent_room_rate_code”=> “21dr-wi4g-aaa9-kg2np”,

“room_type_key”=> “1”,

“rate_plan_key”=> “1”,

“url”=> $hotel_response[‘url’],

“line_items”=> [

[

“price”=> [

“requested_currency_price”=> [

“amount”=> $hotel_response[‘price’][‘total_price’],

“currency”=> $hotel_response[‘price’][‘currency_code’]

]

],

“type”=> $hotel_response[‘price’][‘sub_total’],

“paid_at_checkout”=> false,

], [

“price”=> [

“requested_currency_price”=> [

“amount”=> $hotel_response[‘price’][‘price_per_room_per_night’],

“currency”=> $hotel_response[‘price’][‘currency_code’]

]

],

“type”=> $hotel_response[‘price’][‘tax_amount’],

“sub_type”=> $hotel_response[‘price’][‘tax_percentage’],

“paid_at_checkout”=> false,

]

]

],

]

]

],

“B456″=> [

“response_type”=> “unavailable”

],

“555”=> [

“response_type”=> “error”,

“error”=> [

“error_code”=> 3,

“message”=> “Unknown hotel id was requested.”

]

]

]

 

 

];

echo json_encode($trip_result);

Advertisements