title: Implement XML post request wih PHP
body: <p>I want to call a API call using PHP. It works well when I call the POST request through Postman client. But how can I get same response with PHP?</p>
  <p>Postman POST request url:</p>
  <pre><code>https://apps8.tflite.com/PublicServiceU/Public.svc/asmx
  </code></pre>
  <p>Postman headers:</p>
  <pre><code>Content-Type: text/xml;charset=UTF-8
  Accept-Encoding: gzip,deflate
  SOAPAction: https://apps.contact-technology.co.nz/TakeFlitePublicService/PerformSearch
  </code></pre>
  <p>Postman Body:</p>
  <pre><code>&lt;Envelope xmlns=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
  &lt;Header/&gt;  
        &lt;Body&gt;  
          &lt;PerformSearch xmlns=&quot;https://apps.contact-technology.co.nz/TakeFlitePublicService/&quot;&gt;   
              &lt;SearchClassInstance &gt;  
                 &lt;Adults&gt;1&lt;/Adults&gt;                          
                 &lt;Database&gt;devhinter&lt;/Database&gt;  
                 &lt;From&gt;Cairns&lt;/From&gt;  
                 &lt;To&gt;Coen&lt;/To&gt;  
                 &lt;Date&gt;2022-11-22&lt;/Date&gt;
              &lt;/SearchClassInstance&gt;  
                  &lt;AgentLogin&gt;MyUserName&lt;/AgentLogin&gt;
                  &lt;AgentPassword&gt;MyPassword&lt;/AgentPassword&gt;  
           &lt;/PerformSearch&gt;  
        &lt;/Body&gt;  
     &lt;/Envelope&gt;
  </code></pre>
  <p>The response look like this:</p>
  <pre><code>&lt;s:Envelope xmlns:s=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
      &lt;s:Body xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
          &lt;PerformSearchResponse xmlns=&quot;https://apps.contact-technology.co.nz/TakeFlitePublicService/&quot;&gt;
              &lt;PerformSearchResult&gt;
                  &lt;HasFlights&gt;true&lt;/HasFlights&gt;
                  &lt;OutgoingFlights&gt;
                      &lt;FlightInfo&gt;
                          &lt;ExtensionData/&gt;
                          &lt;Adults&gt;1&lt;/Adults&gt;
                          &lt;ArrivalTime&gt;2022-11-22T09:15:00&lt;/ArrivalTime&gt;
                          &lt;ArriveTimeInlcZoneOffset&gt;2022-11-22T09:15:00&lt;/ArriveTimeInlcZoneOffset&gt;
                          &lt;ChargeDoubleFirstPax&gt;false&lt;/ChargeDoubleFirstPax&gt;
                          &lt;CheckInTime&gt;2022-11-22T06:45:00&lt;/CheckInTime&gt;
                          &lt;CheckInTimeInlcZoneOffset&gt;2022-11-22T06:45:00&lt;/CheckInTimeInlcZoneOffset&gt;
                          &lt;Children&gt;0&lt;/Children&gt;
                          &lt;CustomPax&gt;0&lt;/CustomPax&gt;
                          &lt;DepartTime&gt;2022-11-22T07:30:00&lt;/DepartTime&gt;
                          &lt;DepartTimeInlcZoneOffset&gt;2022-11-22T07:30:00&lt;/DepartTimeInlcZoneOffset&gt;
                          &lt;EarlyBird1&gt;
                              &lt;ExtensionData/&gt;
                              &lt;Adult&gt;0&lt;/Adult&gt;
                              &lt;Allowed&gt;false&lt;/Allowed&gt;
                              &lt;Child&gt;0&lt;/Child&gt;
                              &lt;Custom&gt;0&lt;/Custom&gt;
                              &lt;Explanation/&gt;
                              &lt;FareClass&gt;1&lt;/FareClass&gt;
                              &lt;ID&gt;0&lt;/ID&gt;
                          &lt;/EarlyBird1&gt;
                          &lt;EarlyBird2&gt;
                              &lt;ExtensionData/&gt;
                              &lt;Adult&gt;0&lt;/Adult&gt;
                              &lt;Allowed&gt;false&lt;/Allowed&gt;
                              &lt;Child&gt;0&lt;/Child&gt;
                              &lt;Custom&gt;0&lt;/Custom&gt;
                              &lt;Explanation/&gt;
                              &lt;FareClass&gt;2&lt;/FareClass&gt;
                              &lt;ID&gt;0&lt;/ID&gt;
                          &lt;/EarlyBird2&gt;
                          &lt;FlightNumberString&gt;171&lt;/FlightNumberString&gt;
                          &lt;FloatTypeAny&gt;false&lt;/FloatTypeAny&gt;
                          &lt;From&gt;Cairns&lt;/From&gt;
                          &lt;HasEmptyFlights&gt;true&lt;/HasEmptyFlights&gt;
                          &lt;InactiveOnly&gt;false&lt;/InactiveOnly&gt;
                          &lt;InactiveOnlyReason/&gt;
                          &lt;Leg&gt;1&lt;/Leg&gt;
                          &lt;MultiSector&gt;false&lt;/MultiSector&gt;
                          &lt;NoDiscount&gt;false&lt;/NoDiscount&gt;
                          &lt;NoDropOffs&gt;true&lt;/NoDropOffs&gt;
                          &lt;NoPickups&gt;true&lt;/NoPickups&gt;
                          &lt;PackageFlightNoAdultFare&gt;0&lt;/PackageFlightNoAdultFare&gt;
                          &lt;PackageFlightNoChildFare&gt;0&lt;/PackageFlightNoChildFare&gt;
                          &lt;PackageFlightNoFaresUsed&gt;false&lt;/PackageFlightNoFaresUsed&gt;
                          &lt;PassengerList/&gt;
                          &lt;Passengers&gt;1&lt;/Passengers&gt;
                          &lt;Route&gt;
                              &lt;ExtensionData/&gt;
                              &lt;ArrivalTime&gt;2022-11-22T09:15:00&lt;/ArrivalTime&gt;
                              &lt;BlockedString&gt;Cairns &amp;gt; Coen&lt;/BlockedString&gt;
                              &lt;DepartTime&gt;2022-11-22T07:30:00&lt;/DepartTime&gt;
                              &lt;FlightDuration&gt;105&lt;/FlightDuration&gt;
                              &lt;SectorSummary&gt;Cairns &amp;gt; Coen (171)&lt;/SectorSummary&gt;
                              &lt;Sectors&gt;
                                  &lt;RouteEngineSector&gt;
                                      &lt;ExtensionData/&gt;
                                      &lt;ArrivalTime&gt;2022-11-22T09:15:00&lt;/ArrivalTime&gt;
                                      &lt;DepartTime&gt;2022-11-22T07:30:00&lt;/DepartTime&gt;
                                      &lt;FlightNumber&gt;171&lt;/FlightNumber&gt;
                                      &lt;From&gt;Cairns&lt;/From&gt;
                                      &lt;InactiveOnlyReason/&gt;
                                      &lt;Info&gt;
                                          &lt;ExtensionData/&gt;
                                          &lt;Adult&gt;599.00&lt;/Adult&gt;
                                          &lt;AdultFare&gt;609.00&lt;/AdultFare&gt;
                                          &lt;AdultWebFare&gt;599.00&lt;/AdultWebFare&gt;
                                          &lt;AircraftIDs&gt;
                                              &lt;int&gt;4&lt;/int&gt;
                                          &lt;/AircraftIDs&gt;
                                          &lt;Arrive&gt;2022-11-22T09:15:00&lt;/Arrive&gt;
                                          &lt;ArriveLocal&gt;0001-01-01T00:00:00&lt;/ArriveLocal&gt;
                                          &lt;BackpackerFare&gt;0&lt;/BackpackerFare&gt;
                                          &lt;BackpackerSeatsTaken xsi:nil=&quot;true&quot;/&gt;
                                          &lt;ChargeDoubleFirstPax&gt;false&lt;/ChargeDoubleFirstPax&gt;
                                          &lt;CheckInOffset&gt;0&lt;/CheckInOffset&gt;
                                          &lt;Child&gt;469.00&lt;/Child&gt;
                                          &lt;ChildFare&gt;479.00&lt;/ChildFare&gt;
                                          &lt;ChildWebFare&gt;469.00&lt;/ChildWebFare&gt;
                                          &lt;CustomFare&gt;0&lt;/CustomFare&gt;
                                          &lt;DefaultAirline&gt;Hinterland Aviation &lt;/DefaultAirline&gt;
                                          &lt;DefaultAirlineTimezone&gt;E. Australia Standard Time&lt;/DefaultAirlineTimezone&gt;
                                          &lt;DefaultBagWeight&gt;0&lt;/DefaultBagWeight&gt;
                                          &lt;Depart&gt;2022-11-22T07:30:00&lt;/Depart&gt;
                                          &lt;DepartLocal&gt;0001-01-01T00:00:00&lt;/DepartLocal&gt;
                                          &lt;ExtrasAllowed&gt;true&lt;/ExtrasAllowed&gt;
                                          &lt;FlightNumber&gt;171&lt;/FlightNumber&gt;
                                          &lt;Float&gt;false&lt;/Float&gt;
                                          &lt;From&gt;Cairns&lt;/From&gt;
                                          &lt;FuelSurcharge&gt;0&lt;/FuelSurcharge&gt;
                                          &lt;GateControlUser/&gt;
                                          &lt;International&gt;false&lt;/International&gt;
                                          &lt;MaxBackpackers&gt;0&lt;/MaxBackpackers&gt;
                                          &lt;MaxBagWeight&gt;20&lt;/MaxBagWeight&gt;
                                          &lt;MaxInfantsAllowed&gt;2&lt;/MaxInfantsAllowed&gt;
                                          &lt;MinimumPax&gt;0&lt;/MinimumPax&gt;
                                          &lt;NoDirectFlights&gt;false&lt;/NoDirectFlights&gt;
                                          &lt;NoDiscounts&gt;false&lt;/NoDiscounts&gt;
                                          &lt;NoDropOffs&gt;true&lt;/NoDropOffs&gt;
                                          &lt;NoEarlybirds&gt;false&lt;/NoEarlybirds&gt;
                                          &lt;NoFreight&gt;false&lt;/NoFreight&gt;
                                          &lt;NoPassengers&gt;false&lt;/NoPassengers&gt;
                                          &lt;NoPassengersPublic&gt;false&lt;/NoPassengersPublic&gt;
                                          &lt;NoPassengersPublicExcludingAgents&gt;false&lt;/NoPassengersPublicExcludingAgents&gt;
                                          &lt;NoPickups&gt;true&lt;/NoPickups&gt;
                                          &lt;NoSpecials&gt;false&lt;/NoSpecials&gt;
                                          &lt;Office&gt;Coen&lt;/Office&gt;
                                          &lt;Seats&gt;11&lt;/Seats&gt;
                                          &lt;SeatsAvailable&gt;11&lt;/SeatsAvailable&gt;
                                          &lt;SeatsTaken&gt;0&lt;/SeatsTaken&gt;
                                          &lt;SeatsUsedByAgent&gt;0&lt;/SeatsUsedByAgent&gt;
                                          &lt;SignedOff&gt;false&lt;/SignedOff&gt;
                                          &lt;StatedWeightIncrement&gt;0&lt;/StatedWeightIncrement&gt;
                                          &lt;TSANoFly&gt;false&lt;/TSANoFly&gt;
                                          &lt;TermsID&gt;2221961&lt;/TermsID&gt;
                                          &lt;To&gt;Coen&lt;/To&gt;
                                          &lt;TotalEarlybirds&gt;0&lt;/TotalEarlybirds&gt;
                                          &lt;TotalInfants&gt;0&lt;/TotalInfants&gt;
                                          &lt;TotalSpecials&gt;0&lt;/TotalSpecials&gt;
                                          &lt;TravelID&gt;2945272&lt;/TravelID&gt;
                                          &lt;WeightAvailable&gt;1662&lt;/WeightAvailable&gt;
                                          &lt;WeightMax&gt;1662&lt;/WeightMax&gt;
                                          &lt;WeightTaken&gt;0&lt;/WeightTaken&gt;
                                          &lt;ZonedFlight&gt;false&lt;/ZonedFlight&gt;
                                      &lt;/Info&gt;
                                      &lt;RouteName&gt;OI 171/172&lt;/RouteName&gt;
                                      &lt;SectorNumber&gt;1&lt;/SectorNumber&gt;
                                      &lt;SectorString&gt;sector 1 (Cairns to Coen - 171 (2945272))&lt;/SectorString&gt;
                                      &lt;To&gt;Coen&lt;/To&gt;
                                      &lt;TravelID&gt;2945272&lt;/TravelID&gt;
                                  &lt;/RouteEngineSector&gt;
                              &lt;/Sectors&gt;
                              &lt;StandardPricePerAdult&gt;599.00&lt;/StandardPricePerAdult&gt;
                              &lt;StandardPricePerChild&gt;469.00&lt;/StandardPricePerChild&gt;
                              &lt;StandardPricePerCustom&gt;0&lt;/StandardPricePerCustom&gt;
                              &lt;TravelIDs&gt;2945272&lt;/TravelIDs&gt;
                          &lt;/Route&gt;
                          &lt;SpecialFare&gt;
                              &lt;ExtensionData/&gt;
                              &lt;Adult&gt;0&lt;/Adult&gt;
                              &lt;Allowed&gt;false&lt;/Allowed&gt;
                              &lt;Child&gt;0&lt;/Child&gt;
                              &lt;Custom&gt;0&lt;/Custom&gt;
                              &lt;Explanation/&gt;
                              &lt;FareClass&gt;4&lt;/FareClass&gt;
                              &lt;ID&gt;0&lt;/ID&gt;
                              &lt;TotalPrice&gt;0&lt;/TotalPrice&gt;
                          &lt;/SpecialFare&gt;
                          &lt;StandardAdultFare&gt;549.00&lt;/StandardAdultFare&gt;
                          &lt;StandardChildFare&gt;549.00&lt;/StandardChildFare&gt;
                          &lt;StandardCustomFare&gt;0&lt;/StandardCustomFare&gt;
                          &lt;ThroughFares&gt;
                              &lt;ExtensionData/&gt;
                              &lt;Adult&gt;549.00&lt;/Adult&gt;
                              &lt;Allowed&gt;true&lt;/Allowed&gt;
                              &lt;Backpacker&gt;549.00&lt;/Backpacker&gt;
                              &lt;BackpackerChild&gt;549.00&lt;/BackpackerChild&gt;
                              &lt;Child&gt;549.00&lt;/Child&gt;
                              &lt;Custom&gt;0&lt;/Custom&gt;
                              &lt;Explanation/&gt;
                              &lt;ID&gt;65&lt;/ID&gt;
                              &lt;InfantFare&gt;0&lt;/InfantFare&gt;
                              &lt;TotalPrice&gt;549.00&lt;/TotalPrice&gt;
                          &lt;/ThroughFares&gt;
                          &lt;To&gt;Coen&lt;/To&gt;
                          &lt;TotalSurcharges_Earlybird1&gt;0&lt;/TotalSurcharges_Earlybird1&gt;
                          &lt;TotalSurcharges_Earlybird2&gt;0&lt;/TotalSurcharges_Earlybird2&gt;
                          &lt;TotalSurcharges_Special&gt;0&lt;/TotalSurcharges_Special&gt;
                          &lt;TotalSurcharges_Standard&gt;0&lt;/TotalSurcharges_Standard&gt;
                          &lt;TotalTaxes_Earlybird1&gt;0&lt;/TotalTaxes_Earlybird1&gt;
                          &lt;TotalTaxes_Earlybird2&gt;0&lt;/TotalTaxes_Earlybird2&gt;
                          &lt;TotalTaxes_Special&gt;0&lt;/TotalTaxes_Special&gt;
                          &lt;TotalTaxes_Standard&gt;0&lt;/TotalTaxes_Standard&gt;
                          &lt;TravelIDs&gt;2945272&lt;/TravelIDs&gt;
                          &lt;WeightAvailable&gt;1662&lt;/WeightAvailable&gt;
                          &lt;WeightMaxAllowed&gt;1662&lt;/WeightMaxAllowed&gt;
                          &lt;ZoneOffsetArrive&gt;0&lt;/ZoneOffsetArrive&gt;
                          &lt;ZoneOffsetDepart&gt;0&lt;/ZoneOffsetDepart&gt;
                          &lt;ZonedFlightAll&gt;false&lt;/ZonedFlightAll&gt;
                          &lt;ZonedFlightAny&gt;false&lt;/ZonedFlightAny&gt;
                      &lt;/FlightInfo&gt;
                  &lt;/OutgoingFlights&gt;
                  &lt;PackageID&gt;0&lt;/PackageID&gt;
                  &lt;PackageMode&gt;false&lt;/PackageMode&gt;
                  &lt;ReturnFlights/&gt;
                  &lt;CreditCardSurcharge&gt;2.00000&lt;/CreditCardSurcharge&gt;
              &lt;/PerformSearchResult&gt;
          &lt;/PerformSearchResponse&gt;
      &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  <p>This is my PHP code:</p>
  <pre><code>&lt;?php
  
  $url = &quot;https://apps8.tflite.com/PublicServiceU/Public.svc/asmx&quot;;
  
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_USERPWD, &quot;Corp2:cairns2&quot;);
  $headers = array(
      &quot;Content-type: text/xml;charset=utf-8&quot;,
      &quot;Accept-Encoding: gzip,deflate&quot;,
      &quot;SOAPAction: https://apps.contact-technology.co.nz/TakeFlitePublicService/PerformSearch&quot;
  );
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  
  $data = '
  &lt;Envelope xmlns=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
  &lt;Header/&gt;  
        &lt;Body&gt;  
          &lt;PerformSearch xmlns=&quot;https://apps.contact-technology.co.nz/TakeFlitePublicService/&quot;&gt;   
              &lt;SearchClassInstance &gt;  
                 &lt;Adults&gt;1&lt;/Adults&gt;                          
                 &lt;Database&gt;devhinter&lt;/Database&gt;  
                 &lt;From&gt;MyUserName&lt;/From&gt;  
                 &lt;To&gt;MyPassword&lt;/To&gt;  
                 &lt;Date&gt;2022-11-22&lt;/Date&gt;
              &lt;/SearchClassInstance&gt;  
                  &lt;AgentLogin&gt;Corp2&lt;/AgentLogin&gt;
                  &lt;AgentPassword&gt;cairns2&lt;/AgentPassword&gt;  
           &lt;/PerformSearch&gt;  
        &lt;/Body&gt;  
     &lt;/Envelope&gt;';
  
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  $resp = curl_exec($curl);
  curl_close($curl);
  var_dump($resp);
  die();
  ?&gt;
  </code></pre>
  <p>the result for var_dump look like this:
  <a href="https://i.stack.imgur.com/MlNDj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MlNDj.png" alt="enter image description here" /></a></p>
  <p>How can I correctly implement this? I want to get a readable response same as getting from Postman client.</p>