setHotel($hotel_id); $wc->makeArrival($arrive_date); $wc->makeDepart($depart_date); $wc->addTravelers($travelers_array); //see addTravels comment for info $wc->addRoomNumber($rooms_number); $status=$wc->doRequest("hotelCheck"); if($staus===false){ //get errors array $status=$wc->error; } $results=$wc->wcObject['NexRes']['response'][0]['searchResults'][0]['hotelMatches'][0]['match']; --area hotel seach $wc=new wctravel($session_id); $wc->makeArrival($timestamp); $wc->makeAddress($street,$city,$state,$postal,$country); $wc->makeMaxDistance($milesDistance); $wc->limitSearch($limit); $status=$wc->doRequest("findHotel"); if($staus===false){ //get errors array $status=$wc->error; } */ class wctravel{ var $xmlHost="xmltest.res99.com"; var $xmlService; var $clientId="";//enter client id var $xmlRequest; var $xmlData; var $xmlResponse; var $requestType; var $requestXml; var $sessionId; var $wcObject; var $error; var $hasError; function wctravel($session){ $this->requestType=array( 'findHotel'=>'PropertySearch', //replaced by local db content, but can be used 'hotelInfo'=>'PropertyInformation', 'hotelCheck'=>'PropertyAvailability', 'rates'=>'RateRules', 'bookIt'=>'BookReservation', 'viewIt'=>'ViewReservation', 'cancelIt'=>'CancelReservation' ); $this->requestXml=""; $this->sessionId=$session; $this->xmlService="http://{$this->xmlHost}/xml/xps.cgi"; $this->hasError=false; $this->error=array(); } function doRequest($type){ //set_time_limit(40); $valid=array_key_exists($type,$this->requestType); if($valid!==false){ $requestStart="{$this->sessionId}"; $requestStart.="{$this->clientId}"; $requestStart.="Y"; $requestStart.="requestType[$type]."\">"; $requestEnd=""; $request="$requestStart{$this->requestXml}$requestEnd"; //$request=str_replace("\n","",$request); $request=str_replace("\t","",$request); $request=str_replace("\n","",$request); # Using the cURL extension to send it off, # first creating a custom header block $header[] = "Host: ".$this->xmlHost; $header[] = "Content-type: text/xml"; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $this->xmlService); curl_setopt($ch, CURLOPT_TIMEOUT, 900); curl_setopt($ch, CURLOPT_CONNECTIONTIMEOUT, 30); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); $this->xmlResponse = curl_exec( $ch ); curl_close($ch); $this->requestXml=''; //print_r($this->xmlResponse); $this->processResponse($type); $valid=$this->requestErrors(); } return $valid; } function processResponse($type){ $xmlObj = new XmlToArray($this->xmlResponse); $this->wcObject=false; $this->wcObject=$xmlObj->createArray(); } function makeArrival($timestamp){ $month=date("m",$timestamp*1); $day=date("d",$timestamp*1); $year= date("Y",$timestamp*1); $dateXml="$month$day$year"; $this->requestXml.= $dateXml; } function makeDepart($timestamp){ $month=date("m",$timestamp*1); $day=date("d",$timestamp*1); $year= date("Y",$timestamp*1); $dateXml="$month$day$year"; $this->requestXml.= $dateXml; } function makeAddress($street='',$city='',$state='',$postal='',$country=''){ $addressXml="$street$city$state"; $addressXml.="$postal$countryY"; $this->requestXml.=$addressXml; } function makeMaxDistance($distance=10){ $distanceXml="$distance"; $this->requestXml.=$distanceXml; } function limitSearch($limit=10){ $limitXml="$limit"; $this->requestXml.= $limitXml; } /*pass array array['adult'] =number of adults array['child'] =array(childAge,childAge...) */ function addTravelers($travelers){ $travelXml="".count($travelers['adult']).""; if(!empty($travelers['child'])){ $travelXml.=""; $children=join("",$travelers['child']); $children="$children"; $travelXml.="$children"; } $this->requestXml.= $travelXml; } function addRoomNumber($rooms){ $roomXml="$room"; $this->requestXml.= $roomXml; } function setHotel($hotel){ $hotelXml="$hotel"; $this->requestXml.= $hotelXml; } function requestErrors(){ $errors=false; if(!empty($wcObject['NexRes']['response'][0]['errors'])){ $errors=true; $this->error['errorCode']=$this->wcObject['NexRes']['response'][0]['errors'][0]['error'][0]['code']; $this->error['errorMessage']=@explode(";",$this->wcObject['NexRes']['response'][0]['errors'][0]['error'][0]['message']); } return $errors; } } ?>