Created
July 23, 2015 18:57
-
-
Save matusmarcin/0ddf69548321412a43bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL & ~E_NOTICE); | |
ini_set('display_errors', 1); | |
$_HTTP = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://'; | |
// change this by country (gls-hungary.com, gls-slovakia.sk, gls-czech.com, gls-romania.ro, gls-slovenia.com, gls-croatia.com) | |
$wsdl_path = $_HTTP.'online.gls-slovakia.sk'.'/webservices/soap_server.php?wsdl&ver=14.11.03.01'; | |
$client = new SoapClient($wsdl_path); | |
$in = array( | |
'username' => 'XXXX', | |
'password' => 'xxxxxxxx', | |
'senderid' => '111111111', | |
'sender_name' => 'Firma, s.r.o.', | |
'sender_address' => 'Hlavna 145/51', | |
'sender_city' => 'Košice', | |
'sender_zipcode' => '04001', | |
'sender_country' => 'SK', | |
'sender_contact' => 'Jozef Mrkva', | |
'sender_phone' => '0908xxxxxx', | |
'sender_email' => 'info@firma.fi', | |
'consig_name' => 'Peter Zákazník', | |
'consig_address' => 'Košická 15', | |
'consig_city' => 'Prešov', | |
'consig_zipcode' => '04012', | |
'consig_country' => 'SK', | |
'consig_contact' => 'Peter Zákazník', | |
'consig_phone' => '0908xxxxxx', | |
'consig_email' => 'peter@zakaznikfamily.sk', | |
'pcount' => 1, | |
'pickupdate' => date('Y-m-d'), | |
'content' => '', | |
'clientref' => '124', | |
'codamount' => '99', | |
'codref' => 'codref', | |
'services' => array( | |
array('code' => 'FDS', 'info' => 'peter@zakaznikfamily.sk') | |
), | |
'printertemplate' => 'A4_2x2', | |
'printit' => true, | |
'timestamp' => date('YmdHis'), | |
'hash' => 'xsd:string', | |
'customlabel' => false ); | |
$in['hash'] = getHash($in); | |
$return = $client->__soapCall('printlabel', $in); | |
if ($return) { | |
if ($return->successfull) { | |
header('Content-type: application/pdf'); | |
die(base64_decode($return->pdfdata)); | |
} else { | |
var_dump($return); | |
} | |
} | |
function getHash($data) { | |
$hashBase = ''; | |
foreach($data as $key => $value) { | |
if ($key != 'services' | |
&& $key != 'hash' | |
&& $key != 'timestamp' | |
&& $key != 'printit' | |
&& $key != 'printertemplate' | |
&& $key != 'customlabel') { | |
$hashBase .= $value; | |
} | |
} | |
return sha1($hashBase); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment