File: D:/HostingSpaces/SBogers10/molennooitgedagtbudel.nl/wwwroot/kms/bestelling_label_printen.php
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include_once('sendcloudApi.php');
$parcel_id = $_GET['parcel_id'];
$parcel_ids = explode(",", $parcel_id );
$api = new SendcloudApi('live', 'jlp63pqdPXz3Ef5qXFXq','My4Tkw05JEWvjSb');
$label = $api->label->create(array('parcels' => $parcel_ids));
// https://docs.sendcloud.sc/api/v2/shipping/#bulk-pdf-label-printing
$print_link = $label['normal_printer'][0];
//
//$print_link = str_replace('https://', 'https://jlp63pqdPXz3Ef5qXFXq:My4Tkw05JEWvjSb@', $print_link);
//die($print_link);
//header('Location: '.$print_link);
//exit;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $print_link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "jlp63pqdPXz3Ef5qXFXq:My4Tkw05JEWvjSb");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
$data = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if ($err) {
print_r($err);
exit;
}
header('Content-Type: application/pdf');
echo $data;
exit;
// This is depreciated because sendcloud has changed their routes of the printer to .cs instead of .nl
// $pdf_link = str_replace('https://panel.sendcloud.nl','https://jlp63pqdPXz3Ef5qXFXq:My4Tkw05JEWvjSb@panel.sendcloud.nl',$print_link);
// var_dump($print_link);
// die();
// $pdf_link = str_replace('https://panel.sendcloud.sc','https://jlp63pqdPXz3Ef5qXFXq:My4Tkw05JEWvjSb@panel.sendcloud.sc',$print_link);
// $pdf_link = $print_link;
//header ('HTTP/1.1 301 Moved Permanently');
//header ('Location: '.$pdf_link);
//exit;
?>