我想做一個網站至極具有搜索功能。在這個我不得不做搜索航班,酒店等,有人建議我使用這個皮艇api。我爲此搜尋了每一件事。但我沒有任何想法。任何人都可以建議我如何在我的網站中使用這個api。與皮艇的皮船api
謝謝。
我這樣試過。在這裏我被困住了。
<? 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);
?>
感謝您的回覆。這是我的代碼 – 2010-11-03 10:21:42
我認爲Kayak關閉他們的API ... http://www.kayak.com/labs/api/ – ImadT 2015-04-07 22:14:31