Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //extract data from the post
- extract($_POST);
- $session=$_POST['session'];
- $search = json_decode($_POST['search'],true);
- $data_flight=json_decode($_POST['data_filght'],true);
- /* echo $session;
- echo '<pre>' . print_r($data_flight['Flight_Detail'], true) . '</pre>';
- echo '<pre>' . print_r($search, true) . '</pre>'; */
- $count_depart = count($data_flight['Flight_Detail']['Departure']);
- $count_return = count ($data_flight['Flight_Detail']['Return']);
- $origin = $search['originCode'];
- $dest = $search['destinationCode'];
- $depart_date = $search['departureDate'];
- $return_date = $search['returnDate'];
- $adult = $search['adult'];
- $child = $search['children'];
- $infant = $search['infant'];
- //set POST variables
- $url = 'https://www.patihgo.com/airline.intl/ota_api_dev';
- if($count_depart == 1){
- $field_array = Array (
- 0=> Array (
- 'Origin' => 'CGK',
- 'Destination' => 'SIN',
- 'Flight_Number' => 'GA 88',
- 'Marketing_Airline' => 'GA',
- 'DepartureDateTime' => '2015-09-26T20:50',
- 'ArrivalDateTime' => '2015-09-26T23:50',
- 'Flight_Class' => 'H',
- )
- );
- }else {
- $field_array = Array (
- 0 => $field_loop,
- 1 => $field_loop
- );
- }
- $fields = Array (
- 'Account_Api_Login' => Array (
- 'Agent_Code' => 'E3B5A', //PatihGo Sub Agent Code
- 'Username' => 'I1L3B2', //PatihGo Username Credential
- 'Password' => 'I235BA35',
- ),
- 'Session' => $session, //Session From Availability
- 'Method' => 'Ota_Book',
- 'Ota_Book' => Array (
- 'Origin' => $origin,
- 'Dest' => $dest,
- 'DepartureDate' => $depart_date,
- 'ReturnDate' =>$return_date,
- 'Adult' => $adult,
- 'Children' => $child,
- 'Infant' => $infant,
- 'Departure_Route' => $field_array,
- 'Pax_Detail' => Array (
- 'Contact_Name_Salutation' => 'MR',
- 'Contact_First_Name' => 'Ary',
- 'Contact_Last_Name' => 'Safitry',
- 'Contact_Email' => 'dennyalvin23@gmail.com',
- 'Contact_Phone' => '08145612154',
- 'Adult' => Array (
- 0 => Array (
- 'Salutation' => 'MRS',
- 'First_Name' => 'Ary',
- 'Last_Name' => 'Safitri',
- 'Phone_Number' => '0814532123',
- 'Email' => 'dennyalvin23@gmail.com',
- ),
- ),
- )
- )
- );
- echo '<pre>' . print_r($fields, true) . '</pre>';
- exit();
- //url-ify the data for the POST
- $field_string = http_build_query($fields);
- //open connection
- $ch = curl_init();
- //set the url, number of POST vars, POST data
- curl_setopt($ch,CURLOPT_URL, $url);
- curl_setopt($ch,CURLOPT_POSTFIELDS, $field_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- //execute post
- $result = curl_exec($ch);
- print_r($result);
- //close connection
- curl_close($ch);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement