Perl Fax – Query Submitted Faxes Using FaxQuery2

Download the Perl fax code samples.

The following Perl fax snippet shows information on different submitted faxes. This example illustrates the use of the FaxQuery2 method to retrieve detailed information about a submitted Perl fax.

The FaxQuery2 method provides more advanced querying options than FaxQuery (for more details, see Side-by-side Comparison of Web Service Methods).

The Perl fax script below displays information for submitted faxes:


#/**************** Settings begin **************/
my $username  = ''; # Enter your Interfax username here
my $password  = ''; # Enter your Interfax password here
#   See https://www.interfax.net/en/dev/webservice/reference/faxquery2
#   for an explanation of properties
#
#   Valid values for [property]_verb are:
#   Equals | GreaterThan | GreaterOrEqual | LessThan | LessOrEqual | Like | IncludedIn | Between
#   Leave both [property]_verb and [property]_data empty to ignore the property in the query
my $queryForm = {};
$queryForm->{'Subject'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'FaxNumber'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'FaxNumber'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'DateFrom'} = "2000-01-01T00:00:00.000Z";
$queryForm->{'DateTo'} = "2999-12-31T21:59:59.000Z";
$queryForm->{'UserID'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'ReplyAddress'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'TransactionID'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'ParentTransactionID'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'Status'} = {('Verb', 'Equals', 'VerbData', '')};
$queryForm->{'ShowHiddenTransactions'} = 'true';
my $queryControl = {};
$queryControl->{'OnlyParents'} = 'false';
$queryControl->{'NumOfResults'} = 999;
$queryControl->{'StartingRecord'} = 0;
#   Valid values for $order_by are:
#   TransactionID | SubmitTime | CompletionTime | Status | DestinationFax | Subject | PagesSent | UserID | ReplyEmail
$queryControl->{'OrderBy'} = 'TransactionID';
$queryControl->{'AscOrderDirection'} = 'true';
$queryControl->{'ReturnItems'} = 'true';
$queryControl->{'ReturnStats'} = 'true';
my $NS = 'https://www.interfax.cc';
#/**************** Settings end ****************/


my $client = SOAP::Lite
    ->uri($NS)
    ->on_action( sub { join '/', $NS, $_[1] } ) 
    ->proxy('https://ws.interfax.net/dfs.asmx?WSDL');
    
my $result = $client
    ->call(SOAP::Data->name('FaxQuery2')->attr({xmlns => $NS}) =>
            SOAP::Data->name('Username')->value($username),
            SOAP::Data->name('Password')->value($password),
            SOAP::Data->name('QueryForm')->value($queryForm),
            SOAP::Data->name('QueryControl')->value($queryControl)
    );


if ( $result->fault ) {
    print $result->faultstring . "\n";
} else {
    if( $result->valueof('//FaxQuery2Result/ResultCode') == 0 ) {
        my @fax_items = $result->valueof('//FaxQuery2Result/FaxItems/*');
        print "Displaying information for " . @fax_items . " faxes." . "\n";
        for(my $i=0; $i valueof('//FaxQuery2Result/ResultCode') . "\n";
    }
}