CampaignMonitor::getCampaignBounces PHP Method

getCampaignBounces() public method

Returns a list of all subscribers who bounced for a given campaign, and the type of bounce ("Hard"=Hard Bounce, "Soft"=Soft Bounce).
public getCampaignBounces ( string $campaignId, int[optional] $page = 1, int[optional] $pageSize = 1000, string[optional] $orderField = 'date', string[optional] $orderDirection = 'asc' ) : array
$campaignId string The ID of the campaign you want data for.
$page int[optional]
$pageSize int[optional]
$orderField string[optional]
$orderDirection string[optional]
return array
    public function getCampaignBounces($campaignId, $page = 1, $pageSize = 1000, $orderField = 'date', $orderDirection = 'asc')
    {
        // set parameters
        $parameters['page'] = (int) $page;
        $parameters['pagesize'] = (int) $pageSize;
        $parameters['orderfield'] = (string) $orderField;
        $parameters['orderdirection'] = (string) $orderDirection;
        // make the call
        $records = (array) $this->doCall('campaigns/' . $campaignId . '/bounces', $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) {
            $results[$key]['email'] = $record['EmailAddress'];
            $results[$key]['list_id'] = $record['ListID'];
            $results[$key]['bounce_type'] = $record['BounceType'];
            $results[$key]['date'] = $record['Date'];
            $results[$key]['Reason'] = $record['Reason'];
        }
        // return the records
        return $results;
    }