HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/pmw24/pmw_live_testing/app/vendor/vinceg/usps-php-api/demos/priority_label.php
<?php

require_once('autoload.php');

// Initiate and set the username provided from usps
$label = new \USPS\PriorityLabel('xxxx');

// During test mode this seems not to always work as expected
$label->setTestMode(true);

$label->setFromAddress('John', 'Doe', '', '5161 Lankershim Blvd', 'North Hollywood', 'CA', '91601', '# 204', '', '8882721214');
$label->setToAddress('Vincent', 'Gabriel', '', '230 Murray St', 'New York', 'NY', '10282');
$label->setWeightOunces(1);
$label->setField(36, 'LabelDate', '03/12/2014');

//$label->setField(32, 'SeparateReceiptPage', 'true');

// Perform the request and return result
$label->createLabel();

//print_r($label->getArrayResponse());
//print_r($label->getPostData());
//var_dump($label->isError());

// See if it was successful
if ($label->isSuccess()) {
    //echo 'Done';
    //echo "\n Confirmation:" . $label->getConfirmationNumber();

    $label = $label->getLabelContents();

    if ($label) {
        $contents = base64_decode($label);
        header('Content-type: application/pdf');
        header('Content-Disposition: inline; filename="label.pdf"');
        header('Content-Transfer-Encoding: binary');
        header('Content-Length: '.strlen($contents));
        echo $contents;
        exit;
    }
} else {
    echo 'Error: '.$label->getErrorMessage();
}