CampaignMonitor::getBouncedSubscribers PHP Method

getBouncedSubscribers() public method

Returns a list of all subscribers for a list that have hard bounced since the specified date.
public getBouncedSubscribers ( string[optional] $listId = null, int[optional] $timestamp = null, int[optional] $page = 1, int[optional] $pageSize = 1000, string[optional] $orderField = 'date', string[optional] $orderDirection = 'asc' ) : array
$listId string[optional]
$timestamp int[optional]
$page int[optional]
$pageSize int[optional]
$orderField string[optional]
$orderDirection string[optional]
return array
    public function getBouncedSubscribers($listId = null, $timestamp = null, $page = 1, $pageSize = 1000, $orderField = 'date', $orderDirection = 'asc')
    {
        // set ID
        $listId = empty($listId) ? $this->getListId() : $listId;
        // check timestamp
        if (empty($timestamp)) {
            $timestamp = strtotime('last week');
        }
        // set parameters
        $parameters['date'] = (string) date('Y-m-d', $timestamp);
        $parameters['page'] = (int) $page;
        $parameters['pagesize'] = (int) $pageSize;
        $parameters['orderfield'] = (string) $orderField;
        $parameters['orderdirection'] = (string) $orderDirection;
        // make the call
        $records = (array) $this->doCall('lists/' . $listId . '/bounced', $parameters);
        // stop here if no records were set
        if (empty($records['Results'])) {
            return array();
        }
        // reserve variables
        $results = array();
        // loop the records
        foreach ($records['Results'] as $key => $record) {
            // set values
            $results[$key]['email'] = $record['EmailAddress'];
            $results[$key]['name'] = $record['Name'];
            $results[$key]['date'] = $record['Date'];
            $results[$key]['status'] = $record['State'];
            // check if there are custom fields present
            if (empty($record['CustomFields']['SubscriberCustomField'])) {
                continue;
            }
            // loop records
            foreach ($record['CustomFields']['SubscriberCustomField'] as $field) {
                // set values
                $results[$key]['custom_fields'][$field['Key']] = $field['Value'];
            }
        }
        // return the records
        return $results;
    }