Get information about one or more submitted faxes with FaxQuery

25 Nov 2016 This code sample is deprecated and in process of being removed. Check out our new code libraries and usage documentation on InterFAX @ Github.

This sample demonstrates how to retrieve information about a sent fax using the FaxQuery method. This method has more flexible querying options than FaxStatusEx.

<?php

/**************** Settings begin **************/
 
$username   = '';   // Enter your Interfax username here
$password   = '';   // Enter your Interfax password here
$query_verb = 'LT'; // Very flexible, see documentation
$query_data = '999999999';  //
$max_items  = '10';

/**************** Settings end ****************/

$client = new SoapClient("http://ws.interfax.net/dfs.asmx?wsdl");

$params->Username   = $username;
$params->Password   = $password;
$params->Verb       = $query_verb;
$params->VerbData   = $query_data;
$params->MaxItems   = $max_items;
$params->ResultCode = '';

$queryResult = $client->FaxQuery($params);
$queryCount = count($queryResult->FaxQueryResult->FaxItemEx);

// Format information retrieved from InterFAX
 
if (0 == $queryResult->ResultCode){ // status request succeeded
    switch($queryCount){
        case 0:
            echo 'No transactions fit query';
            break;
 
        case 1: // single item returned by WS call
            echo 'ParentTransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx->ParentTransactionID . '';
            echo 'TransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx->TransactionID . '';
            echo 'SubmitTime: ' . $queryResult->FaxQueryResult->FaxItemEx->SubmitTime . '';
            echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx->PostponeTime . '';
            echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx->CompletionTime . '';
            echo 'UserID: ' . $queryResult->FaxQueryResult->FaxItemEx->UserID . '';
            echo 'Contact: ' . $queryResult->FaxQueryResult->FaxItemEx->Contact . '';
            echo 'DestinationFax: ' . $queryResult->FaxQueryResult->FaxItemEx->DestinationFax . '';
            echo 'ReplyEmail: ' . $queryResult->FaxQueryResult->FaxItemEx->ReplyEmail . '';
            echo 'RemoteCSID: ' . $queryResult->FaxQueryResult->FaxItemEx->RemoteCSID . '';
            echo 'PagesSent: ' . $queryResult->FaxQueryResult->FaxItemEx->PagesSent . '';
            echo 'Status: ' . $queryResult->FaxQueryResult->FaxItemEx->Status . '';
            echo 'Duration: ' . $queryResult->FaxQueryResult->FaxItemEx->Duration . '';
            echo 'Subject: ' . $queryResult->FaxQueryResult->FaxItemEx->Subject . '';
            echo 'PagesSubmitted: ' . $queryResult->FaxQueryResult->FaxItemEx->PagesSubmitted . '';
            echo 'SenderCSID: ' . $queryResult->FaxQueryResult->FaxItemEx->SenderCSID . '';
            echo 'Priority: ' . $queryResult->FaxQueryResult->FaxItemEx->Priority . '';
            echo 'Units: ' . $queryResult->FaxQueryResult->FaxItemEx->Units . '';
            echo 'CostPerUnit: ' . $queryResult->FaxQueryResult->FaxItemEx->CostPerUnit . '';
            echo 'PageSize: ' . $queryResult->FaxQueryResult->FaxItemEx->PageSize . '';
            echo 'PageOrientation: ' . $queryResult->FaxQueryResult->FaxItemEx->PageOrientation . '';
            echo 'PageResolution: ' . $queryResult->FaxQueryResult->FaxItemEx->PageResolution . '';
            echo 'RenderingQuality: ' . $queryResult->FaxQueryResult->FaxItemEx->RenderingQuality . '';
            echo 'PageHeader: ' . $queryResult->FaxQueryResult->FaxItemEx->PageHeader . '';
            echo 'RetriesToPerform: ' . $queryResult->FaxQueryResult->FaxItemEx->RetriesToPerform . '';
            echo 'TrialsPerformed: ' . $queryResult->FaxQueryResult->FaxItemEx->TrialsPerformed . '';
            break;
 
        default: // multiple items returned by WS call
            for($i = 0; $i < $queryCount; $i++){
                echo 'ParentTransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->ParentTransactionID . '';
                echo 'TransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->TransactionID . '';
                echo 'SubmitTime: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->SubmitTime . '';
                echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PostponeTime . '';
                echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->CompletionTime . '';
                echo 'UserID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->UserID . '';
                echo 'Contact: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Contact . '';
                echo 'DestinationFax: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->DestinationFax . '';
                echo 'ReplyEmail: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->ReplyEmail . '';
                echo 'RemoteCSID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->RemoteCSID . '';
                echo 'PagesSent: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PagesSent . '';
                echo 'Status: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Status . '';
                echo 'Duration: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Duration . '';
                echo 'Subject: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Subject . '';
                echo 'PagesSubmitted: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PagesSubmitted . '';
                echo 'SenderCSID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->SenderCSID . '';
                echo 'Priority: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Priority . '';
                echo 'Units: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Units . '';
                echo 'CostPerUnit: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->CostPerUnit . '';
                echo 'PageSize: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageSize . '';
                echo 'PageOrientation: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageOrientation . '';
                echo 'PageResolution: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageResolution . '';
                echo 'RenderingQuality: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->RenderingQuality . '';
                echo 'PageHeader: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageHeader . '';
                echo 'RetriesToPerform: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->RetriesToPerform . '';
                echo 'TrialsPerformed: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->TrialsPerformed . '';
                echo '------------------------------------';
            }  // close loop
                break;
        }  // close switch
} else { // problem getting status
    // Do something here, like alerting an administrator
    echo 'Problem retrieving status';
}
 
?>

Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today