Perl Fax – Retrieve Fax Information with FaxStatus

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.
Download the Perl fax code samples.

Use the FaxStatus method to retrieve information about one or more submitted faxes with Perl.

The following Perl fax script demonstrates the FaxStatus method, displaying information for a number of submitted faxes:


#/**************** Settings begin **************/
my $username  = ''; # Enter your Interfax username here
my $password  = ''; # Enter your Interfax password here
my $lastTransactionID = '999999999';
my $maxItems = '1';
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('FaxStatus')->attr({xmlns => $NS}) =>
            SOAP::Data->name('Username')->value($username)->type(''),
            SOAP::Data->name('Password')->value($password)->type(''),
            SOAP::Data->name('LastTransactionID')->value($lastTransactionID)->type(''),
            SOAP::Data->name('MaxItems')->value($maxItems)->type('')
    );


if ( $result->fault ) {
    print $result->faultstring . "\n";
} else {
    if( $result->valueof('//FaxStatusResponse/ResultCode') == 0 ) {
        my @fax_items = $result->valueof('//FaxStatusResult/*');

        print "Displaying information for " . @fax_items . " faxes." . "\n";
        for(my $i=0; $i valueof('//FaxStatusResponse/ResultCode') . "\n";
    }
}