| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/models/ |
Upload File : |
<?php
class Travel_Model_ApiIntegration {
// public $url='http://api.tektravels.com/SharedServices/SharedData.svc/rest/Authenticate';
// public $urlHotel='http://api.tektravels.com/BookingEngineService_Hotel/hotelservice.svc/rest/GetHotelResult/';
// public $userIp='180.151.8.18';
// public $user="tripshows";
// public $pass="tripshows@123";
// public $clientID='apiintegration';
public function apiAuthentication($clientID,$url,$user,$pass,$userIp){
$data = array(
'ClientId' => $clientID,
'UserName' => $user,
'Password' => $pass,
'EndUserIp' => $userIp
);
$data_string = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
));
$output = curl_exec($ch);
$response = json_decode($output,true);
return $response['TokenId'];
curl_close($ch);
}
public function apiHotelSearch($urlHotel,$userIp,$datah){
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlHotel);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
return $response;
curl_close($ch);
}
public function getHotelInfo($resultIndex,$hotelCode,$userIp,$tokenId,$traceId){
//$hotelInfoURL="http://api.tektravels.com/BookingEngineService_Hotel/hotelservice.svc/rest/GetHotelInfo/";
$datahRoom = array(
"ResultIndex" => $resultIndex,
"HotelCode" => $hotelCode,
"EndUserIp" => $userIp,
"TokenId" => $tokenId,
"TraceId" => $traceId
);
$data_stringh= json_encode($datahRoom);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_INFO);
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
//echo "<pre>";print_r($response);exit;
//Write Response Logs starts...
// $strFilePath = "apihotels/book/".$tokenId."book_response.json";
// Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath,$response);
//Write Response Logs starts...
// added By Pardeep Panchal to update Hotel Amenities got from API
$intResponseStatus = $response['HotelInfoResult']['ResponseStatus'];
if($intResponseStatus == 1){
$arrHotelFacilities = $response['HotelInfoResult']['HotelDetails']['HotelFacilities'];
if(count($arrHotelFacilities) > 0){
$strAmenitiesMasking = Zend_Controller_Action_HelperBroker::getStaticHelper('Masking')->createHotelAmenitiesMasking($arrHotelFacilities);
$objBuyHotel = new Travel_Model_TblBuyHotel();
$dataUpdate = array( 'AccoAminitiesMask' => $strAmenitiesMasking);
$Where['TraceId = ?'] = $traceId;
$Where['ShortName = ?'] = trim($hotelCode);
$objBuyHotel->updateApiHotelAmenities($dataUpdate,$Where);
}
$arrApiHotelImages = $response['HotelInfoResult']['HotelDetails']['Images'];
if(count($arrApiHotelImages) > 0){
$CreateDate = date('Y-m-d H:i:s');
$objHotel = new Travel_Model_TblBuyHotel();
$intAccomSysId = $objHotel->getHotelInfoByShortCode($hotelCode,$traceId);
$sessionhotelDirectSearchData = new Zend_Session_Namespace('sessionHotelDirectSearchData');
$intGTXCityId = $sessionhotelDirectSearchData->params['hotelXrefCityId'];
$Seq = 1;
$intImagesCount = $objHotel->countApiHotelsImages(trim($hotelCode));
if($intImagesCount < 2){
foreach($arrApiHotelImages as $imgValue){
$imgData = array(
'AccomSysId' => $intAccomSysId,
'Seq' => $Seq,
'ImgType' => 2,
'HotelCode' => trim($hotelCode),
'CitySysId' => $intGTXCityId,
'ImageType' => 'FullImage',
'ImageURL' => $imgValue,
'UpdateDate' => $CreateDate,
'CreateDate' => $CreateDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$objHotel->insertApiHotelsImages($imgData);
$Seq++;
}
}
}
}
// added By Pardeep Panchal to update Hotel Amenities got from API
return $response;
curl_close($ch);
}
//this function used for get api images and other result without affecting db created by Er amit kumar dubey on 22 nov 2016 used in proposol/getHotelDetailApiAction
public function getHotelInfoWithoutDb($resultIndex,$hotelCode,$userIp,$tokenId,$traceId){
$hotelInfoURL=TBO_HOTEL_API_HOTEL_INFO;
$datahRoom = array(
"ResultIndex" => $resultIndex,
"HotelCode" => $hotelCode,
"EndUserIp" => $userIp,
"TokenId" => $tokenId,
"TraceId" => $traceId
);
$data_stringh= json_encode($datahRoom);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $hotelInfoURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
curl_close($ch);
return $response;
}
public function getHotelRoomDetail($userIp, $tokenId, $traceId, $resultIndex, $hotelCode) {
//$urlHotelBook = "http://api.tektravels.com/BookingEngineService_Hotel/hotelservice.svc/rest/GetHotelRoom/";
$datahRoom = array(
"ResultIndex" => $resultIndex,
"HotelCode" => $hotelCode,
"EndUserIp" => $userIp,
"TokenId" => $tokenId,
"TraceId" => $traceId
);
$data_stringh = json_encode($datahRoom);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_ROOM_INFO);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH, true);
// echo "<pre>";
// print_r($response);exit;
return $response;
curl_close($ch);
}
public function blockRoom($datahRoom){
//$hotelInfoURL="http://api.tektravels.com/BookingEngineService_Hotel/hotelservice.svc/rest/BlockRoom/";
$data_stringh= json_encode($datahRoom,JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_ROOM_BLOCK);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
curl_close($ch);
return $response;
}
public function bookRoom($datahRoom){
//$hotelInfoURL="http://api.tektravels.com/BookingEngineService_Hotel/hotelservice.svc/rest/Book/";
$data_stringh= json_encode($datahRoom,JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, TBO_HOTEL_API_HOTEL_ROOM_BOOK);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
return $response;
curl_close($ch);
}
public function getBookingDetails($datahRoom){
$hotelInfoURL="http://api.tektravels.com/BookingEngineService_Hotel/HotelService.svc/rest/GetBookingDetail/";
$data_stringh= json_encode($datahRoom,JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $hotelInfoURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
$_SESSION['VOUCHER_DETAIL'] = $response;
//echo "<pre>";
//print_r($_SESSION['VOUCHER_DETAIL']);
return 1 ;
curl_close($ch);
}
public function getBookingDetailsWithSession($datahRoom){
$hotelInfoURL="http://api.tektravels.com/BookingEngineService_Hotel/HotelService.svc/rest/GetBookingDetail/";
$data_stringh= json_encode($datahRoom,JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $hotelInfoURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$response = json_decode($outputH,true);
$VOUCHER_DETAIL = new Zend_Session_Namespace('VOUCHER_DETAIL');
$VOUCHER_DETAIL->VOUCHER_DETAIL=$response;
//echo "<pre>";
//print_r($_SESSION['VOUCHER_DETAIL']);
return $response;
curl_close($ch);
}
}
?>