Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
api
/
dpd
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php header("Content-Type: application/json"); define("DPD_PRINT", "https://api.dpd.ro/v1/print/"); function dpd_print_awb() { $ch = curl_init(); $parcels = array('parcel' => array('id' => $_REQUEST['awb_id'])); $awb_data = array('userName' => $_REQUEST['username_dpd'], 'password' => $_REQUEST['password_dpd'], 'paperSize' => $_REQUEST['format_awb'], 'format' => 'pdf', 'parcels' => array($parcels)); $data = json_encode($awb_data); curl_setopt($ch, CURLOPT_URL, DPD_PRINT); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLINFO_HEADER_OUT, true); $awb = curl_exec($ch); $httpcode = curl_getinfo($ch); $response = json_encode($awb); curl_close($ch); if ($awb) { header('Content-Description: File Transfer'); header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="AWB_DPD_' . $_REQUEST['awb_id'] . '.pdf"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . strlen($awb)); echo $awb; } } if ($_SERVER["REQUEST_METHOD"] == "POST" && $_SERVER["CONTENT_TYPE"] == "application/json") { $data = trim(file_get_contents("php://input")); $json = json_decode($data, true); if (is_array($json)) { $_REQUEST = $json + $_REQUEST; } dpd_print_awb(); } else { http_response_code(405); }