PHP: Get the status of a letter with GetLetterStatus()

This sample uses the GetRequestStatus() method to query a single item.

To query the status of multiple items in a single call, use the GetRequestStatus_Multiple() or GetRequestStatus_Range() methods.

<?php
 
/************* Settings  Begin ****************/
 
$username = '********';
$password = '********';
$id = 99999999; // ID of transaction being queried
 
/************* Settings  End ******************/
 
$soapclient = new SoapClient('http://api.postalmethods.com/PostalWS.asmx?WSDL');
$result = $soapclient->GetLetterStatus(array('Username'    => $username,
                                             'Password'    => $password,
                                             'ID'          => $id));
 
// print_r($result);
 
$result_code = $result->GetLetterStatusResult->ResultCode;
 
if ($result_code == -3000) { 
	$request_status = $result->GetLetterStatusResult->Status;
	$lastupdated    = $result->GetLetterStatusResult->LastUpdateTime;
 
	echo "Letter ID: $id <br>";
	echo "Status: $request_status <br>";
	echo "Last Updated: $lastupdated <br>";
 
} else {
    // System returns error message
    echo "Error: <a href=\"http://www.postalmethods.com/resources/reference/status-codes\">$result_code</a><br>";
}
 
?>