0

I have a php file that is trying to get information from a XML API using SOAP.

The code for pulling data is

 <?php
  // create SOAP client object
  $client = new SoapClient("http://www.bookingassist.ro/test/book.wsdl", array('trace' => 1));

  try {
      $rooms = array(); 
      // First Room
      $rooms[] = array(array("paxType" => "Adult"));
      $filters[] = array("filterType" => "resultLimit", "filterValue" => "6");     
      // (start search)
      $checkAvailability = $client->getAvailableHotel("APIKEY", "RHMK", "2015-04-20", "2015-04-27", "EUR", "RO", "false", $rooms, $filters);
  }
  catch (SoapFault $exception) {
      echo $exception->getMessage();
      exit;
  }

?>
 <?php
  if (is_object($checkAvailability->availableHotels)) 
  $hotelResponse[] = $checkAvailability->availableHotels;
  $hotelResponse = $checkAvailability->availableHotels;
  foreach ((array)$hotelResponse as $hnum => $hotel)
?>  

below in page i have the folowing code

<article class="box">
<h4><?php echo  $hotel->hotelCode?></h4>                                      
<span class="price">aprox/NOAPTE</small>€ <?php echo $hotel->totalPrice ?></span>
</article>

My query is can i loop the entire content from as many responses i have in the filters array ($filters[] = array("filterType" => "resultLimit", "filterValue" => "6"); )

I have tried the same but in a blank page withour any css onky a table with header abd uts extracting and looping the information as requested. - http://www.bookingassist.ro/test/test.php

Razvan
  • 53
  • 10
  • Hi Razvan, welcome to SO. Please reduce the code you post to an absolute, but working minimum, so that it demonstrates what you are asking, but without the complexity. Moreover, please provide the XML itself, also as a working minimum. You will get precise answers then. – michi Dec 11 '14 at 12:32
  • Thanks. I have tried to minimise the code. Hope to find an answer as i am strugling with this for few days, – Razvan Dec 11 '14 at 13:09
  • what does `var_dump($checkAvailability);` get you? – michi Dec 11 '14 at 18:13
  • its pulling and shows 6 responses with all the variables availeble for $checkAvailability eg : object(stdClass)#2 (4) { ["responseId"]=> int(69560) ["searchId"]=> string(11) "XF-51806556" ["totalFound"]=> int(6) ["availableHotels"]=> array(6) { [0]=> object(stdClass)#3 (9) { ["processId"]=> string(11) "H7-24700606" ["hotelCode"]=> string(6) "ITXN2I" ["availabilityStatus"]=> string(19) "InstantConfirmation" ["totalPrice"]=> float(2733) ["totalTax"]=> float(0) ["totalSalePrice"]=> float(0) ["currency"]=> string(3) "EUR etc – Razvan Dec 11 '14 at 18:37
  • as far as I see, this has nothing to do with XML. Pls add this output to your question. rewrite your question. delete the xml tag. – michi Dec 12 '14 at 06:53

1 Answers1

0

If you are only getting one result I don't think the values you have in "$hotelResponse" are what you think.

There's a good chance that your code is entering the second part of your if/else statement explaining why you are only getting one result.

Do a var_dump on this to verify you have X amount of hotels

Carlton
  • 5,533
  • 4
  • 54
  • 73