You are here

function cc::export_contacts in Constant Contact 6.2

Same name and namespace in other branches
  1. 6.3 class.cc.php \cc::export_contacts()
  2. 7.3 class.cc.php \cc::export_contacts()

* This method creates a new export contacts activity * It returns the activity ID to use to check the status * * *

Parameters

array An array: fieldnames to export: see fieldnames.html: * @param int The ID of the list to export * @param string The format of the export, either CSV or TXT * * @access public

File

./class.cc.php, line 944

Class

cc
@file

Code

function export_contacts($list_id, $export_type = 'CSV', $columns = array()) {
  if (!is_array($columns) || !count($columns)) {
    $columns = array(
      'FIRST NAME',
      'MIDDLE NAME',
      'LAST NAME',
      'JOB TITLE',
      'COMPANY NAME',
      'WORK PHONE',
      'HOME PHONE',
      'ADDRESS LINE 1',
      'ADDRESS LINE 2',
      'ADDRESS LINE 3',
      'CITY, STATE',
      'STATE/PROVINCE (US/CANADA)',
      'COUNTRY',
      'POSTAL CODE',
      'SUB POSTAL CODE',
    );
  }
  $params['activityType'] = 'EXPORT_CONTACTS';
  $params['fileType'] = 'CSV';
  $params['exportOptDate'] = 'true';
  $params['exportOptSource'] = 'true';
  $params['exportListName'] = 'false';
  $params['sortBy'] = 'DATE_DESC';
  $params['columns'] = $columns;
  $params['listId'] = $this
    ->get_list_url($list_id);
  $this
    ->http_set_content_type('application/x-www-form-urlencoded');
  $this
    ->load_url("activities", 'post', $params, 201);
  if (isset($this->http_response_headers['Location']) && trim($this->http_response_headers['Location']) != '') {
    return $this
      ->get_id_from_link($this->http_response_headers['Location']);
  }
  return false;
}