Advertisement
nmfuadi

data_book

Jul 24th, 2015
3,344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. //extract data from the post
  4. extract($_POST);
  5. $session=$_POST['session'];
  6. $search = json_decode($_POST['search'],true);
  7. $data_flight=json_decode($_POST['data_filght'],true);
  8.  
  9. /* echo $session;
  10. echo '<pre>' . print_r($data_flight['Flight_Detail'], true) . '</pre>';
  11.    echo '<pre>' . print_r($search, true) . '</pre>'; */
  12.  
  13. $count_depart = count($data_flight['Flight_Detail']['Departure']);
  14. $count_return = count ($data_flight['Flight_Detail']['Return']);
  15. $origin = $search['originCode'];
  16. $dest = $search['destinationCode'];
  17. $depart_date = $search['departureDate'];
  18. $return_date = $search['returnDate'];
  19. $adult = $search['adult'];
  20. $child = $search['children'];
  21. $infant = $search['infant'];
  22.  
  23. //set POST variables
  24. $url = 'https://www.patihgo.com/airline.intl/ota_api_dev';
  25.  
  26. if($count_depart == 1){
  27. $field_array = Array (
  28.                        
  29.                          0=> Array (
  30.                                 'Origin' => 'CGK',
  31.                                 'Destination' => 'SIN',
  32.                                 'Flight_Number' => 'GA 88',
  33.                                 'Marketing_Airline' => 'GA',
  34.                                 'DepartureDateTime' => '2015-09-26T20:50',
  35.                                 'ArrivalDateTime' => '2015-09-26T23:50',
  36.                                 'Flight_Class' => 'H',
  37.                             )  
  38.                        
  39.                         );
  40.         }else {
  41.        
  42.                
  43.        
  44.                 $field_array = Array (
  45.                        
  46.                        
  47.                        
  48.                         0 => $field_loop,
  49.                         1 => $field_loop
  50.                        
  51.                         );
  52.                    
  53.        
  54.         }
  55.  
  56. $fields = Array (
  57.                     'Account_Api_Login' => Array (
  58.                     'Agent_Code' => 'E3B5A',  //PatihGo Sub Agent Code
  59.                     'Username' => 'I1L3B2',  //PatihGo Username Credential
  60.                     'Password' => 'I235BA35',
  61.             ),
  62.                 'Session' => $session,  //Session From Availability
  63.                 'Method' => 'Ota_Book',
  64.                     'Ota_Book' => Array (
  65.                         'Origin' => $origin,
  66.                         'Dest' => $dest,
  67.                         'DepartureDate' => $depart_date,
  68.                         'ReturnDate' =>$return_date,
  69.                         'Adult' => $adult,
  70.                         'Children' => $child,
  71.                         'Infant' => $infant,
  72.                         'Departure_Route' => $field_array,
  73.                        
  74.             'Pax_Detail' => Array (
  75.                             'Contact_Name_Salutation' => 'MR',
  76.                             'Contact_First_Name' => 'Ary',
  77.                             'Contact_Last_Name' => 'Safitry',
  78.                             'Contact_Email' => 'dennyalvin23@gmail.com',
  79.                             'Contact_Phone' => '08145612154',
  80.                             'Adult' => Array (
  81.                                 0 => Array (
  82.                                     'Salutation' => 'MRS',
  83.                                     'First_Name' => 'Ary',
  84.                                     'Last_Name' => 'Safitri',
  85.                                     'Phone_Number' => '0814532123',
  86.                                     'Email' => 'dennyalvin23@gmail.com',
  87.                                 ),
  88.                                    
  89.                                
  90.                             ),
  91.                         )
  92.                     )
  93.             );
  94.            
  95.            
  96.             echo '<pre>' . print_r($fields, true) . '</pre>';
  97.             exit();
  98.  
  99. //url-ify the data for the POST
  100. $field_string = http_build_query($fields);
  101.  
  102. //open connection
  103. $ch = curl_init();
  104.  
  105. //set the url, number of POST vars, POST data
  106. curl_setopt($ch,CURLOPT_URL, $url);
  107. curl_setopt($ch,CURLOPT_POSTFIELDS, $field_string);
  108. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  109.  
  110. //execute post
  111. $result = curl_exec($ch);
  112.  
  113. print_r($result);
  114.  
  115.  
  116. //close connection
  117. curl_close($ch);
  118.  
  119. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement