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>

when i call api directly to browser i got right data in xml format.


but when i call it through curl.. sometime i get data in json format or sometimes no data..

$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;

help me.

thanks in advance

Recommended Answers

All 6 Replies

try to set the CURLOPT_HTTPHEADER something like this:
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") );

does not change anything.. the api above works.. so you can test it and try to call it from curl.. try some changes in code.. if it works thn reply.. thanks

no help..??? :O

Here ya go...
you need to add an _type variable to your request.
right after currency code and before xml=...
add &_type=xml so:
...&locale=en_US&currencyCode=USD&_type=xml&xml=<HotelListReq...
&_type=xml will give you an xml response type.

thanks for the reply.. yeah that the problem.. :)

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>

Result:
<ns2:HotelListResponse xmlns:ns2="http://v3.hotel.wsapi.ean.com/">
<EanWsError>
<itineraryId>-1</itineraryId>
<handling>RECOVERABLE</handling>
<category>AUTHENTICATION</category>
<exceptionConditionId>-1</exceptionConditionId>
<presentationMessage>TravelNow.com cannot service this request.</presentationMessage>
<verboseMessage>
Authentication failure. (cid=55505; ipAddress=202.131.119.234)
</verboseMessage>
</EanWsError>
<customerSessionId>0ABAA8D7-AC1C-A914-C4B2-3A9B58901903</customerSessionId>
</ns2:HotelListResponse>

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.