Right.

Im trying to communicate with the expedia travel API, exchanging xml feed with them.
It goes somehow like this:
I send them info of the query I want, they send me the query back in xml form.
Here is an example of a query I would want to send them:

http:/api.ean.com/ean-services/rs/hotel/v3/list?minorRev=5&cid=55505&apiKey=4zckao5ucpwuabf3egk25bt7&customerUserAgent=[xxx]&customerIpAddress=172.1682.13&locale=en_US&currencyCode=USD&xml=<HotelListRequest><city>Seattle</city><stateProvinceCode>WA</stateProvinceCode><countryCode>US</countryCode><arrivalDate>08/01/2011</arrivalDate><departureDate>08/03/2011</departureDate><RoomGroup><Room><numberOfAdults>2</numberOfAdults></Room></RoomGroup><numberOfResults>1</numberOfResults></HotelListRequest>

Notice if you put that into the urlbar of your browser, you get an xml feed on the screen. (I have changed the apiKey, so all you get is Developer Inactive), in reality you would get an xml feed like this:

<ns2:HotelListResponse>
<customerSessionId>0ABAA856-94D0-1913-0762-FCBF069040C5</customerSessionId>
<numberOfRoomsRequested>1</numberOfRoomsRequested>
<moreResultsAvailable>true</moreResultsAvailable>
<cacheKey>-24c94d01:13076fcbf06:-40c3</cacheKey>
<cacheLocation>10.186.168.86:7302</cacheLocation>
−
<HotelList activePropertyCount="231" size="1">
−
<HotelSummary order="0">
<hotelId>176580</hotelId>
<name>Best Western Airport Executel</name>
<address1>20717 International Blvd</address1>
<city>SeaTac</city>
<stateProvinceCode>WA</stateProvinceCode>
<postalCode>98198</postalCode>
<countryCode>US</countryCode>
<airportCode>SEA</airportCode>
<supplierType>E</supplierType>
<propertyCategory>1</propertyCategory>
<hotelRating>2.5</hotelRating>
<confidenceRating>78</confidenceRating>
<amenityMask>165374346</amenityMask>
<tripAdvisorRating>3.5</tripAdvisorRating>
<locationDescription>Near the airport</locationDescription>
−
<shortDescription>
&lt;p&gt;&lt;strong&gt;Location.&lt;/strong&gt; &lt;br /&gt;Located in SeaTac, Best Western Airport Executel is near the airport and close to Hydroplane and Raceboat Museum. Other points of interest are ShoWare Center and
</shortDescription>
<highRate>80.09</highRate>
<lowRate>80.09</lowRate>
<rateCurrencyCode>USD</rateCurrencyCode>
<latitude>47.41617</latitude>
<longitude>-122.29722</longitude>
<proximityDistance>15.536363</proximityDistance>
<proximityUnit>MI</proximityUnit>
<hotelInDestination>true</hotelInDestination>
<thumbNailUrl>/hotels/1000000/30000/22900/22893/22893_61_t.jpg</thumbNailUrl>
−
<deepLink>
http://travel.ian.com/index.jsp?pageName=hotAvail&amp;cid=55505&amp;hotelID=176580&amp;mode=2&amp;numberOfRooms=1&amp;room-0-adult-total=2&amp;room-0-child-total=0&amp;arrivalMonth=7&amp;arrivalDay=1&amp;departureMonth=7&amp;departureDay=3&amp;showInfo=true&amp;locale=en_US&amp;currencyCode=USD
</deepLink>
−
<RoomRateDetailsList>
−
<RoomRateDetails>
<roomTypeCode>16240</roomTypeCode>
<rateCode>200058358</rateCode>
<maxRoomOccupancy>3</maxRoomOccupancy>
<quotedRoomOccupancy>2</quotedRoomOccupancy>
<minGuestAge>0</minGuestAge>
<roomDescription>Standard Room Queen Bed-NonRefundable</roomDescription>
<currentAllotment>13</currentAllotment>
<propertyAvailable>true</propertyAvailable>
<propertyRestricted>false</propertyRestricted>
<expediaPropertyId>22893</expediaPropertyId>
<rateKey>c1e905de-4084-48e1-a607-081b74148642</rateKey>
−
<RateInfo rateChange="false" promo="false" priceBreakdown="true">
−
<ChargeableRateInfo commissionableUsdTotal="160.18" total="183.88" surchargeTotal="23.7" nightlyRateTotal="160.18" averageBaseRate="80.09" averageRate="80.09" maxNightlyRate="80.09" currencyCode="USD">
−
<NightlyRatesPerRoom size="2">
<NightlyRate promo="false" rate="80.09" baseRate="80.09"/>
<NightlyRate promo="false" rate="80.09" baseRate="80.09"/>
</NightlyRatesPerRoom>
−
<Surcharges size="1">
<Surcharge amount="23.7" type="TaxAndServiceFee"/>
</Surcharges>
</ChargeableRateInfo>
</RateInfo>
−
<ValueAdds size="3">
−
<ValueAdd id="2">
<description>Continental Breakfast</description>
</ValueAdd>
−
<ValueAdd id="32768">
<description>Free Airport Shuttle</description>
</ValueAdd>
−
<ValueAdd id="1024">
<description>Free High-Speed Internet</description>
</ValueAdd>
</ValueAdds>
</RoomRateDetails>
</RoomRateDetailsList>
</HotelSummary>
</HotelList>
</ns2:HotelListResponse>

The thing is though, I want to send this feed to the server(not redirect the page), and then read the xml data and post it on the screen in my application. For an easy example, how would I go about extracting the name of the hotel and the price.

I tried loading the xml by putting the xml request(what you put in the url bar) into a variable called $query.
And then:
$doc = new DOMDocument();
$doc->load($query);

But I get an error saying something like:
Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http:/api.ean.com/ean-services/rs/hotel/v3/list?minorRev=5bla bla.

Any ideas?

Well yes, but loading a simple file like they show there with only normal url with some get data is no problem. What I mean is when I try sending data like xml tags and so on, something goes wrong.
Im thinking I must need to format the xml tags with urlencode function or something before I send it over.
It seems they are dealing with the same thing on this thread here:
http://www.webmasterworld.com/php/3975943.htm
but still I dont get it too work.

Seems Im getting a bit closer.
It seems I managed to send the xml over, now I would need to read what comes back in return.

<?php

$url = "http://api.ean.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=5&apiKey=4zckao5ucpwuabf3egk25bt7&locale=en_US&currencyCode=USD&customerIpAddress=172.16.82.13&customerUserAgent=Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-GB;+rv:1.9.2.10)+Gecko/20100914+Firefox/3.6.10&customerSessionId=&xml=";

$post_string = '<?xml version="1.0" encoding="UTF-8"?>
<HotelListRequest><arrivalDate>07/01/2011</arrivalDate><departureDate>07/03/2011</departureDate><RoomGroup><Room><numberOfAdults>1</numberOfAdults><numberOfChildren>1</numberOfChildren><childAges>1</childAges></Room></RoomGroup><city>London</city><countryCode>GB</countryCode></HotelListRequest>';


$header  = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n"; 
$header .= $post_string;

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);

$data = curl_exec($ch);

if(curl_errno($ch))
    print curl_error($ch);
else
    curl_close($ch);

?>

I split the send request to two parts, the get data and the xml string. The obvious problem here being Im using get and post intermixed.
But you get where I am going with this.
1. How can I ship an url with get or post data, including xml tags over to another url and then catch what comes up in return on the other end.
2. How can I display the results from the xml coming from the other url on my screen.

Hello Friend..

i m also using the expedia api version 3.. and facing the same problem. if i pass url directly on browser i get the xml output.. but when i send the url through curl n get nothing.. herer is my code..

<?php

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://api.ean.com/ean-services/rs/hotel/v3/list?minorRev=4&cid=55505&apiKey=5q4gzx43g6ukcrq798z2hz75&customerSessionId=&locale=en_US&currencyCode=USD&xml=<HotelListRequest><city>new%20delhi</city><RoomGroup><Room><numberOfAdults>2</numberOfAdults><numberOfResults></numberOfResults></Room></RoomGroup></HotelListRequest>");
        curl_setopt($ch, CURLOPT_FAILONERROR,1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
          
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        $retValue = curl_exec($ch);                      
        curl_close($ch);
        
        echo $retValue;

thanks in advance.

Why do i get this output...

0ABAA82D-9BED-DC91-3252-09CDE0D90D260false342674Blue Cliffs Retreat239 Hepburn Newstead RoadElevated PlainsVC3461AU 54.052169044096In the historical district&lt;p&gt;&lt;b&gt;Location. &lt;/b&gt; &lt;br /&gt;Located in Elevated Plains, Blue Cliffs Retreat is near the airport and in the historical district. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Property Features. &lt;/b&gt;&lt;br /&gt;Recreational amenities include 51048.8295.14USD-37.28366144.123215.297255MIfalse/hotels/4000000/3500000/3496800/3496702/3496702_1_t.jpghttp://travel.ian.com/index.jsp?pageName=hotAvail&amp;cid=55505&amp;hotelID=342674&amp;mode=2&amp;numberOfRooms=1&amp;room-0-adult-total=2&amp;room-0-child-total=0&amp;showInfo=true&amp;locale=en_US&amp;currencyCode=USD256471Novotel Forest Resort1500 Midland HighwayCreswickVC3363AUMEL44.552168354187In the mountains&lt;p&gt;&lt;b&gt;Location. &lt;/b&gt; &lt;br /&gt;Located in Creswick, Novotel Forest Resort is in a state/national park and close to Calembeen Park. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Property Features. &lt;/b&gt;&lt;br /&gt;Novotel Forest Resort features a249.0696151.09USD-37.44065143.8918815.054599MIfalse/hotels/2000000/1700000/1697600/1697570/1697570_65_t.jpghttp://travel.ian.com/index.jsp?pageName=hotAvail&amp;cid=55505&amp;hotelID=256471&amp;mode=2&

etc....

when i use this piece of code?

<?php
 header("Content-Type: text/xml");
 $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://api.ean.com/ean-services/rs/hotel/v3/list?minorRev=4&cid=55505&apiKey=5q4gzx43g6ukcrq798z2hz75&customerSessionId=&locale=en_US&currencyCode=USD&_type=xml&xml=<HotelListRequest><city>daylesford</city><RoomGroup><Room><numberOfAdults>2</numberOfAdults><numberOfResults></numberOfResults></Room></RoomGroup></HotelListRequest>");
        curl_setopt($ch, CURLOPT_FAILONERROR,1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
          
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        $retValue = curl_exec($ch);                      
         
		curl_close($ch);
        echo $retValue;
        
?>

and how do i get it to display correctly?

anyone?

I dont know, but I have already solved this expedia thing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.