Quantcast
Channel: SBZ Systems
Viewing all articles
Browse latest Browse all 1958

Courier API 1.0 –Διασύνδεση εταιριών ταχυμεταφορών (courier) με την EMDI

$
0
0

Στο αρχείο courier.ini που βρίσκεται στο κύριο φάκελο της EMDI ορίζουμε τους συνδέσμους:

[print]
speedex=https://www.sbzsystems.com/apps/emdi/courier.php?action=printspeedex&voucher=#voucherno
elta=C:\Program Files (x86)\ELTA_COURIER\ELTA_PRINT_SETUP\ELTA_PRINT.exe #senderid #courieruser #courierpass #voucherno
acs=https://www.sbzsystems.com/apps/emdi/courier.php?action=printacs&voucher=#voucherno
[general]
temp=https://www.sbzsystems.com/apps/emdi/tmp/
script=https://www.sbzsystems.com/apps/emdi/courier.php

Οι μεταβλητές:
#senderid             Κωδικός αποστολέα
#courieruser        Χρήστης σύνδεσης
#courierpass        Κωδικός σύνδεσης
#cpuser                 Χρήστης
#cppass                 Κωδικός
#voucherno          Αριθμός voucher

Κλήσεις στο διαδίκτυο

Η EMDI καλεί αντίστοιχα τους παρακάτω συνδέσμους:

Δημιουργία voucher

{script}?courier=&rec_date=&courieruser=&courierpass=&cpuser=&cppass=&senderid=&rec_name=&rec_address=&rec_area=&rec_zip=&rec_telephone=&rec_mobile=&quantity=&weight=&notes=&cashondelivery=&relateddoc=&rec_country=GR&sendername=&action=print&emdiuser=&saturday=&exact=&special=

Άνοιγμα voucher

{script}?courier=&rec_date=&courieruser=&courierpass=&cpuser=&cppass=&senderid=&relateddoc=&voucher=&action=view&emdiuser=&lang=

Ακύρωση voucher

{script}?courier=&rec_date=&courieruser=&courierpass=&cpuser=&cppass=&senderid=&relateddoc=&voucher=&action=cancel&emdiuser=&lang=

Η εκτύπωση λαμβάνεται από το σύνδεσμο που έχει ορισθεί στην αντίστοιχη εταιρία στην ενότητα [print]

 

Ενδεικτικά το php script που λαμβάνει τις κλήσεις από την EMDI:

<?php

require_once('courier_common.php');


$couriername = $_GET['courier'];
$courieruser = $_GET['courieruser'];
$courierpass = $_GET['courierpass'];
$cpuser = $_GET['cpuser'];
$cppass = $_GET['cppass'];
$senderid = $_GET['senderid'];
$rec_name = $_GET['rec_name'];
$rec_address = $_GET['rec_address'];
$rec_area = $_GET['rec_area'];
$rec_zip = $_GET['rec_zip'];

$rec_telephone = $_GET['rec_telephone'];
$rec_mobile = $_GET['rec_mobile'];

$quantity = $_GET['quantity'];
$weight = $_GET['weight'];
$notes = $_GET['notes'];
$cashondelivery = $_GET['cashondelivery'];
$relateddoc = $_GET['relateddoc'];
$rec_country = $_GET['rec_country'];
$rec_date = $_GET['rec_date'];
$sendername = $_GET['sendername'];
$action = $_GET['action'];
$emdiuser = $_GET['emdiuser'];
$voucher = $_GET['voucher'];
$saturday = $_GET['saturday']; //elta ΠΑΡΑΔΟΣΗ ΣΑΒΒΑΤΟ
$exact = $_GET['exact']; // ΠΡΟΚΑΘΟΡΙΣΜΕΝΗ ΩΡΑ
$special = $_GET['special']; //ΕΙΔΙΚΗ ΔΙΑΧΕΙΡΙΣΗ
$lang = $_GET['lang'];


$soapurl='';
$logfile='/home/sbz/domains/sbzsystems.com/public_html/apps/emdi/courier.log';

//


	$messages['Show voucher list'] = 'Εμφάνιση λίστας voucher';
	$messages['Create voucher receipt list'] = 'Δημιουργία λίστας παραλαβής voucher';
	$messages['Voucher'] = 'Voucher';
	$messages['Date'] = 'Ημερομηνία';
	$messages['Notes'] = 'Σημειώσεις';




if (($couriername=='speedex') || ($action=='printspeedex') || ($action=='receiptspeedex') || ($action=='cancelspeedex')) {
	require_once('courier_speedex.php');
}


?>

To script για τη speedex:

<?php
	$userUN='speedex_';
	
	
	$soapurl='http://www.speedex.gr/AccessPointTest/AccessPoint.asmx';
	//$soapurl='http://www.speedex.gr/accesspoint/accesspoint.asmx';
	
	
	if ($action=='print') {
		
		open_session();
		
		
		
		$rec_date=substr($rec_date,0,4).'-'.substr($rec_date,4,2).'-'.substr($rec_date,6,2);
		
		$weight=number_format($weight, 2, '.', '');
		if  ($weight<0.5) { $weight=0.5; }
		$quantity=round(number_format($quantity, 2, '.', ''));
		$cashondelivery=number_format($cashondelivery, 2, '.', '');
		
		if ($cashondelivery<>0) {
			$paymenttype='Μ';
			} else {
			$paymenttype='';
		}
		
		if ($exact) { $exact='2'; } else { $exact='0'; } 
		
		
		if ($rec_telephone=='') {
			$rec_telephone=  explode(',', $rec_mobile)[0];
			$rec_mobile=  explode(',', $rec_mobile)[1];
		}
		
		
		
		
		$soap_request  = '
		
		
		<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
		<soap:Header/>
		<soap:Body>
		<spe:CreateBOLwithOrder>		
		<spe:sessionID>'.$sessionid.'</spe:sessionID>		
		<spe:inListPod>
		<spe:BOLOrder>               
		<spe:voucher_code></spe:voucher_code>
		<spe:EnterBranchId>'.$cpuser.'</spe:EnterBranchId>
		<spe:charge_Customer_Id>'.$senderid.'</spe:charge_Customer_Id>
		<spe:charge_agreement_id>'.$cppass.'</spe:charge_agreement_id>
		<spe:SND_Company></spe:SND_Company>
		<spe:SND_Name>'.$sendername.'</spe:SND_Name>
		<spe:SND_Addr1></spe:SND_Addr1>
		<spe:SND_Addr2></spe:SND_Addr2>
		<spe:SND_Zip_Code></spe:SND_Zip_Code>
		<spe:SND_City></spe:SND_City>
		<spe:SND_Tel1></spe:SND_Tel1>
		<spe:SND_Tel2></spe:SND_Tel2>
		<spe:RCV_Afm></spe:RCV_Afm>
		<spe:RCV_DOY></spe:RCV_DOY>
		<spe:RCV_Company></spe:RCV_Company>
		<spe:RCV_Name>'.$rec_name.'</spe:RCV_Name>
		<spe:RCV_Addr1>'.$rec_address.'</spe:RCV_Addr1>
		<spe:RCV_Addr2></spe:RCV_Addr2>
		<spe:RCV_Zip_Code>'.$rec_zip.'</spe:RCV_Zip_Code>
		<spe:RCV_City>'.$rec_area.'</spe:RCV_City>
		<spe:RCV_Country>'.$rec_country.'</spe:RCV_Country>
		<spe:RCV_Tel1>'.$rec_telephone.'</spe:RCV_Tel1>
		<spe:RCV_Tel2>'.$rec_mobile.'</spe:RCV_Tel2>
		<spe:Voucher_Weight>'.$weight.'</spe:Voucher_Weight>
		<spe:Pod_Amount_Cash>'.$cashondelivery.'</spe:Pod_Amount_Cash>
		<spe:Security_Value>0</spe:Security_Value>
		<spe:Express_Delivery>0</spe:Express_Delivery>
		<spe:Saturday_Delivery>'.$saturday.'</spe:Saturday_Delivery>
		<spe:Time_Limit>'.$exact.'</spe:Time_Limit>
		<spe:Comments_2853_1></spe:Comments_2853_1>
		<spe:Comments_2853_2></spe:Comments_2853_2>
		<spe:Comments_2853_3></spe:Comments_2853_3>
		<spe:Comments>'.$notes.'</spe:Comments>
		<spe:Voucher_Volume>0</spe:Voucher_Volume>
		<spe:Pod_Amount_Description>'.$paymenttype.'</spe:Pod_Amount_Description>
		<spe:PayCode_Flag>1</spe:PayCode_Flag>
		<spe:BranchBankCode></spe:BranchBankCode>
		<spe:Paratiriseis_2853_1></spe:Paratiriseis_2853_1>
		<spe:Paratiriseis_2853_2></spe:Paratiriseis_2853_2>
		<spe:Paratiriseis_2853_3></spe:Paratiriseis_2853_3>
		<spe:email></spe:email>
		<spe:BasicService></spe:BasicService>
		<spe:Items>'.$quantity.'</spe:Items>
		<spe:Vouc_descr></spe:Vouc_descr>
		<spe:Comments_new></spe:Comments_new>
		<spe:_cust_Flag>0</spe:_cust_Flag>
		<spe:orderPickupDate>'.$rec_date.'</spe:orderPickupDate>
		<spe:orderPickupTimeFrom></spe:orderPickupTimeFrom>
		<spe:orderPickupTimeto></spe:orderPickupTimeto>
		<spe:returnFlag>0</spe:returnFlag>
		<spe:originalvoucher></spe:originalvoucher>
		<spe:originalkey1></spe:originalkey1>
		<spe:originalkey2></spe:originalkey2>
		<spe:originalkey3></spe:originalkey3>
		<spe:sendparalavi>0</spe:sendparalavi>		
		</spe:BOLOrder>
		</spe:inListPod>
		<spe:tableFlag>3</spe:tableFlag>
		</spe:CreateBOLwithOrder>
		</soap:Body>
		</soap:Envelope>
		
		
		
		';
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		$header = array(
		"Content-type: text/xml;charset=\"utf-8\"",
		"Accept: text/xml",
		"Cache-Control: no-cache",
		"Pragma: no-cache",
		//	"SOAPAction: \"run\"",
		"Content-length: ".strlen($soap_request),
		);
		
		$soap_do = curl_init();
		curl_setopt($soap_do, CURLOPT_URL, $soapurl );
		curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
		curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
		curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($soap_do, CURLOPT_POST,           true );
		curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
		curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
		
		$result = curl_exec($soap_do);
		
		$xmlerr=get_between($result,'<returnMessage>','</returnMessage>');
		$xmlres=get_between($result,'<voucher_code>','</voucher_code>');
		
		$xmlres=html_entity_decode($xmlres);
		$xmlerr=html_entity_decode($xmlerr);
		
		
		//CREATE PDF	
		$soap_request  = '
		
		<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
		<soap:Header/>
		<soap:Body>
		<spe:GetBOLPdf>         
		<spe:sessionID>'.$sessionid.'</spe:sessionID>         
		<spe:voucherIDs>      
		<spe:string>'.$xmlres.'</spe:string>
		</spe:voucherIDs>
		<spe:perVoucher>1</spe:perVoucher>
		<spe:paperType>1</spe:paperType>
		</spe:GetBOLPdf>
		</soap:Body>
		</soap:Envelope>
		';
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		$header = array(
		"Content-type: text/xml;charset=\"utf-8\"",
		"Accept: text/xml",
		"Cache-Control: no-cache",
		"Pragma: no-cache",
		//"SOAPAction: \"run\"",
		"Content-length: ".strlen($soap_request),
		);
		
		$soap_do = curl_init();
		curl_setopt($soap_do, CURLOPT_URL, $soapurl );
		curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
		curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
		curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($soap_do, CURLOPT_POST,           true );
		curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
		curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
		
		$result = curl_exec($soap_do);	
		
		$pdf=get_between($result,'<pdf>','</pdf>');	
		$pdf=html_entity_decode($pdf);
		
		
		//	file_put_contents($logfile, '#'.$pdf.'#', FILE_APPEND | LOCK_EX);
		
		
		$file = fopen('tmp/'.$userUN.$xmlres.'.pdf', "w+");
		fputs($file, base64_decode($pdf) );
		fclose($file);
		
		
		
		
		echo $xmlres.'|'.$xmlerr;
		
		
		
		close_session();
		
		
	}
	
	
	//SPEEDEX PRINT VOUCHER
	if ($action=='printspeedex')  {
		
		
		
	?>	
	<script type="text/javascript">
		
		window.location.href = "tmp/<?php echo $userUN.$voucher; ?>.pdf";
		
	</script>	
	<?php
		
	}
	

	
	
	
	
	
	
	
	
	
	if ($action=='view')  {
		
		open_session();
		
		$soap_request  = '
		<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
		<soap:Header/>
		<soap:Body>
		<spe:GetTraceByVoucher>
		<spe:sessionID>'.$sessionid.'</spe:sessionID>
		<spe:VoucherID>'.$voucher.'</spe:VoucherID>
		</spe:GetTraceByVoucher>
		</soap:Body>
		</soap:Envelope>		
		';
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		//	file_put_contents($logfile, '#'.$soap_request.'#', FILE_APPEND | LOCK_EX);
		
		
		$header = array(
		"Content-type: text/xml;charset=\"utf-8\"",
		"Accept: text/xml",
		"Cache-Control: no-cache",
		"Pragma: no-cache",
		//	"SOAPAction: \"run\"",
		"Content-length: ".strlen($soap_request),
		);
		
		$soap_do = curl_init();
		curl_setopt($soap_do, CURLOPT_URL, $soapurl );
		curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
		curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
		curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($soap_do, CURLOPT_POST,           true );
		curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
		curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
		
		$result = curl_exec($soap_do);
		
		
		
		//$xmlres=$result;<returnMessage>Invalid RCV_Tel1</returnMessage><
		$xmlres=get_between($result,'<returnMessage>','</returnMessage>');		
		$xmlres=html_entity_decode($xmlres);
		
		
		
		close_session();
		
		
	
	
 
	
	$xmlres=$messages['Voucher'].': '.$voucher.'<br>'.		
	//$messages['Date'].': '.get_between($result,'<diak_dateparal xsi:type="xsd:dateTime" xsi:nil="true">','</diak_dateparal>').'<br>'.
	$messages['Notes'].': '.$xmlres;
	
	$xmlres=html_entity_decode($xmlres);
	
	
	
	
	
	?>
	
	
	<head>
		
		<title></title>
	</head>	
	<body style="font-family: Arial, Helvetica, sans-serif; font-size: small;">
		
		
		<?php
			echo $xmlres;
			
			//if (file_exists('tmp/'.$userUN.$emdiuser.$courieruser.'.txt')) {
			$prox="https://www.sbzsystems.com/apps/emdi/courier.php?courier=speedex&emdiuser=$emdiuser&courieruser=$courieruser&courierpass=$courierpass&cpuser=$cpuser&cppass=$cppass&action=receiptspeedex";
		?>
		<br><br>
		<a href="<?php echo $prox; ?>" target="_blank"><?php echo $messages['Show voucher list']; ?></a>
		
		<?php 
			//echo showresults('tmp/'.$userUN.$emdiuser.$courieruser.'.txt');
			//}
			
			
			
			
			
			
		?>
	</body>	
</html>
<?php
	
	
	
}


if ($action=='receiptspeedex')  {
	
	
	// CREATE ReceiptsList		
	/*
		$rec_date='';
		$all=file_get_contents('tmp/'.$userUN.$emdiuser.$courieruser.'.txt');
		$larray = explode("\n", $all);
		foreach ($larray as $item) {
		$narray = explode(";", $item);
		if ($narray[0]) {
		$sessionid=$narray[2];
		$rec_date=$narray[1];
		last;
		}
		}		
	*/
	open_session();
	$rec_date=date("Y-m-d");//   substr($rec_date,0,4).'-'.substr($rec_date,4,2).'-'.substr($rec_date,6,2);
	
	//file_put_contents($logfile, '#'.$rec_date.'#'.$xmlres."##\n", FILE_APPEND | LOCK_EX);
	
	
	// CREATE ReceiptsList	
	$soap_request  = '
	
	<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
	<soap:Header/>
	<soap:Body>
	<spe:GetBOLSummaryPdf>
	<spe:sessionID>'.$sessionid.'</spe:sessionID>
	<spe:beginDate>'.$rec_date.'T00:00:00</spe:beginDate>
	<spe:endDate>'.$rec_date.'T23:59:59</spe:endDate>
	</spe:GetBOLSummaryPdf>
	</soap:Body>
	</soap:Envelope>
	
	';
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	$header = array(
	"Content-type: text/xml;charset=\"utf-8\"",
	"Accept: text/xml",
	"Cache-Control: no-cache",
	"Pragma: no-cache",
	//"SOAPAction: \"run\"",
	"Content-length: ".strlen($soap_request),
	);
	
	$soap_do = curl_init();
	curl_setopt($soap_do, CURLOPT_URL, $soapurl );
	curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
	curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($soap_do, CURLOPT_POST,           true );
	curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
	curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
	
	$result = curl_exec($soap_do);
	
	$pdf=get_between($result,'<GetBOLSummaryPdfResult>','</GetBOLSummaryPdfResult>');	
	$xmlerr=get_between($result,'<soap:Text xml:lang="en">','</soap:Text>');	
	
	$pdf=html_entity_decode($pdf);
	$xmlerr=html_entity_decode($xmlerr);
	
	
	//file_put_contents($logfile, '#'.$soap_request.'#'.$xmlerr, FILE_APPEND | LOCK_EX);
	//file_put_contents($logfile, '#'.$pdf.'#', FILE_APPEND | LOCK_EX);	
	
	$file = fopen('tmp/'.$userUN.$emdiuser.$courieruser.'.pdf', "w+");
	fputs($file, base64_decode($pdf) );
	fclose($file);
	
	//$fp = fopen('tmp/'.$userUN.$emdiuser.$courieruser.'.pdf', 'w');
	//fwrite($fp, $response);
	//fclose($fp);	
	
	
	
	unlink('tmp/'.$userUN.$emdiuser.$courieruser.'.txt');
	
	
	
	close_session();
	////////////////
	///////////////////
	///////////////
	
	
?>	
<script type="text/javascript">
	
	window.location.href = "tmp/<?php echo $userUN.$emdiuser.$courieruser; ?>.pdf";
	
</script>	
<?php
	
	
	
	
	
	
	
}















if ($action=='cancelspeedex')  {
	
	open_session();
	// CANCEL ReceiptsList	
	$soap_request  = '
	
	<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
	<soap:Header/>
	<soap:Body>
	<spe:CancelBOL>
	<spe:sessionID>'.$sessionid.'</spe:sessionID>
	<spe:voucherID>'.$voucher.'</spe:voucherID>
	</spe:CancelBOL>
	</soap:Body>
	</soap:Envelope>
	
	
	';
	
	$header = array(
	"Content-type: text/xml;charset=\"utf-8\"",
	"Accept: text/xml",
	"Cache-Control: no-cache",
	"Pragma: no-cache",
	//"SOAPAction: \"run\"",
	"Content-length: ".strlen($soap_request),
	);
	
	$soap_do = curl_init();
	curl_setopt($soap_do, CURLOPT_URL, $soapurl );
	curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
	curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($soap_do, CURLOPT_POST,           true );
	curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
	curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
	
	$result = curl_exec($soap_do);
	
	
	//file_put_contents($logfile, '#'.$result.'#', FILE_APPEND | LOCK_EX);
	
	close_session();
}



//////////////////////////////////////////////////////////////////
//////////////////// functions ///////////////////////////////////
//////////////////////////////////////////////////////////////////





function open_session() {
	
	
	
	
	//OPEN SESSION
	$soap_request  = '
	<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
	<soap:Header/>
	<soap:Body>
	<spe:CreateSession>		
	<spe:username>'.$GLOBALS['courieruser'].'</spe:username>		
	<spe:password>'.$GLOBALS['courierpass'].'</spe:password>
	</spe:CreateSession>
	</soap:Body>
	</soap:Envelope>
	';
	
	
	//file_put_contents($logfile, '#'.$soap_request.'#', FILE_APPEND | LOCK_EX);
	
	
	$header = array(
	"Content-type: text/xml;charset=\"utf-8\"",
	"Accept: text/xml",
	"Cache-Control: no-cache",
	"Pragma: no-cache",
	//"SOAPAction: \"run\"",
	"Content-length: ".strlen($soap_request),
	);
	
	$soap_do = curl_init();
	curl_setopt($soap_do, CURLOPT_URL, $GLOBALS['soapurl'] );
	curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
	curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($soap_do, CURLOPT_POST,           true );
	curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
	curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
	
	$result = curl_exec($soap_do);	
	$sessionid=get_between($result,'<sessionId>','</sessionId>');
	$xmlerr=get_between($result,'<returnMessage>','</returnMessage>');
	
	$GLOBALS['xmlerr']=html_entity_decode($xmlerr);
	$GLOBALS['sessionid']=html_entity_decode($sessionid);
	
	
}













function close_session() {
	//CLOSE SESSION
	
	$soap_request  = '
	<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:spe="http://www.speedex.gr/">
	<soap:Header/>
	<soap:Body>
	<spe:DestroySession>
	<spe:sessionID>'.$GLOBALS['sessionid'].'</spe:sessionID>
	</spe:DestroySession>
	</soap:Body>
	</soap:Envelope>
	';
	
	//file_put_contents($logfile, '#'.$soap_request.'#', FILE_APPEND | LOCK_EX);
	
	
	$header = array(
	"Content-type: text/xml;charset=\"utf-8\"",
	"Accept: text/xml",
	"Cache-Control: no-cache",
	"Pragma: no-cache",
	//"SOAPAction: \"run\"",
	"Content-length: ".strlen($soap_request),
	);
	
	$soap_do = curl_init();
	curl_setopt($soap_do, CURLOPT_URL, $GLOBALS['soapurl']);
	curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
	curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($soap_do, CURLOPT_POST,           true );
	curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
	curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
	
	$result = curl_exec($soap_do);	
}



?>

 


Viewing all articles
Browse latest Browse all 1958