Inbound: get list of inbound faxes using GetList

This sample demonstrates how to retrieve a list of inbound (received) faxes.

The sample uses method GetList.

<?php
 
/**************** Settings begin **************/
 
$username  = ''; // Enter your Interfax username here
$password  = ''; // Enter your Interfax password here
$listtype  = 'NewMessages'; // Enter the type of list you wish to return 
$maxitems  = '10'; // Maximum number of inbound faxes to return in list
 
/**************** Settings end ****************/
 
$client = new SoapClient("http://ws.interfax.net/inbound.asmx?wsdl");
 
$params->Username  = $username;
$params->Password  = $password;
$params->LType	   = $listtype;
$params->MaxItems  = $maxitems;
 
$result = $client->GetList($params);
 
//print_r($result);
 
if (!$result->GetListResult){ // WS call successful
	if (count($result->objMessageItem->MessageItem) > 0) { 
		// the returned list is not empty
		if (count($result->objMessageItem->MessageItem) == 1 ){ 
			// there is exactly one item in returned list
			foreach ($result->objMessageItem AS $inboundfax){
			echo 'Message ID: ' . $inboundfax->MessageID . '<br>'; 
			echo 'Phone Number: ' . $inboundfax->PhoneNumber . '<br>';
			echo 'Remote CSID: ' . $inboundfax->RemoteCSID . '<br>';
			echo 'Message Status: ' . $inboundfax->MessageStatus . '<br>';
			echo 'Pages: ' . $inboundfax->Pages . '<br>';
			echo 'Message Size: ' . $inboundfax->MessageSize . '<br>';
			echo 'Message Type: ' . $inboundfax->MessageType . '<br>';
			echo 'Receive Time: ' . $inboundfax->ReceiveTime . '<br>';
			echo 'Caller ID: ' . $inboundfax->CallerID . '<br>';
			echo 'Message Recording Duration: ' . $inboundfax->MessageRecordingDuration . '<br><br>';
			}
		} else { 
			// there are two or more items returned in the list
			foreach ($result->objMessageItem->MessageItem AS $inboundfax){
			echo 'Message ID: ' . $inboundfax->MessageID . '<br>'; 
			echo 'Phone Number: ' . $inboundfax->PhoneNumber . '<br>';
			echo 'Remote CSID: ' . $inboundfax->RemoteCSID . '<br>';
			echo 'Message Status: ' . $inboundfax->MessageStatus . '<br>';
			echo 'Pages: ' . $inboundfax->Pages . '<br>';
			echo 'Message Size: ' . $inboundfax->MessageSize . '<br>';
			echo 'Message Type: ' . $inboundfax->MessageType . '<br>';
			echo 'Receive Time: ' . $inboundfax->ReceiveTime . '<br>';
			echo 'CallerID: ' . $inboundfax->CallerID . '<br>';
			echo 'Message Recording Duration: ' . $inboundfax->MessageRecordingDuration . '<br><br>';;
			}
		}
	} else { 
		// the returned list is empty
		echo 'No inbound faxes in list';
}
} else { // Bad WS call
	echo 'WS call failed';
}
?>