i want to do a website wich is having search functionality. in this i have to do search flights,hotels etc.., some one suggested me to use kayak api for this. i searched every thing for this. but i didn’t get any idea. anyone could suggest me how to use this api in my site.
thanks.
i ust tried like this. here i was stucked.
<? ob_start(); session_start();
$hostname="http://www.kayak.com";
$token="mCHpMz2L_a_OrEkz3FSiDg";//"mCHpMz2L_a_OrEkz3FSiDg";
$sessionid=""; $searchid="";
$searchtype=""; $lastcount="";
class ksearchphpExample {
public function ksearchJavaExample($args){
/*print_r($args); echo
count($args);exit;*/ if(count($args)
< 4 || count($args) > 5) {
echo("USAGE:\n".
"ksearchJavaExample f ORIGIN_AIPORT DESTINATION_AIRPORT
DEPART_DATE [RETURN_DATE]\n".
"ksearchjavaExample h \"city, RC, CC\" CHECKIN_DATE CHECKOUT_DATE\n" );
exit(); }
$searchtype='h'; //$args[0].charAt(0);
$sessionid= getsession(); echo("Session ID:\t".$sessionid );
if($searchtype == 'f' ){ $searchid= start_flight_search("n",
$args[1],$args[2],$args[3],$args[4] );
}
if( $searchtype == 'h'){ $searchid=
start_hotel_search($args[1],$args[2],$args[3]);
} echo("Search ID:\t".$searchid);
while (pollResults()) {
echo("waiting for more..."); } }
private function getsession(){
echo("Token:\t\t".$token ); $xml
= simplexml_load_file($hostname."/k/ident/apisession?token=".$token
);
echo $xml->getName() . "<br />";
foreach($xml->children() as $child)
{ echo $child->getName() . ": " .
$child . "<br />"; }
$response=get($hostname+"/k/ident/apisession?token=".$token
);
$root=xmlRoot($response); $sessionid=$root.getElementsByTagName("sid");
if( $sessionid.getLength() == 0){
echo("BAD TOKEN: ".$response);
exit(1); } return
$sessionid.item(0).getFirstChild().getNodeValue();
}
//private function fetch($urlstring){
// $content = ""; // // try {
// $url = new URL($urlstring);
// InputStream is =
url.openStream(); //
BufferedReader d = new
BufferedReader(new
InputStreamReader(is)); //
String s; // // while
(null != (s = d.readLine())) { //
content = content + s + "\n"; //
} // is.close(); //
// } catch ( Exception e ) {
System.out.println(e.getMessage() ); }
// return content; // } //
// public static void main(String[]
args) { // ksearchJavaExample ks =
new ksearchJavaExample(args); // }
} $kps=new ksearchphpExample();
$arg= array
('h','hyderabad,india','03/11/2010','05/11/2010');
echo $kps->ksearchJavaExample($arg);
?>
http://www.kayak.com/labs/api/search/
Seems like you need to get a developer key. Once you’ve got that, you can POST their server for data, and parse the XML they return (note that their searches take 30-60 seconds to complete, so you have to request a search, catch the Search ID, then check back for the results using the Search ID). Check out the API spec.