You are here

function cc::get_emails in Constant Contact 7.3

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

Gets all account email addresses or a single email.

These are used with the campaigns collection.

@access public

1 call to cc::get_emails()
cc::create_campaign in ./class.cc.php
Creates a new campaign.

File

./class.cc.php, line 1452
Constant Contact PHP Class

Class

cc
@file Constant Contact PHP Class

Code

function get_emails($return_email = '') {
  $xml = $this
    ->load_url("settings/emailaddresses");
  if (!$xml) {
    return FALSE;
  }

  // Parse into nicer array.
  $emails = array();
  $_emails = isset($xml['feed']['entry']) ? $xml['feed']['entry'] : FALSE;
  if (is_array($_emails)) {
    if (isset($_emails[0]['link_attr']['href'])) {
      foreach ($_emails as $k => $v) {
        $id = $this
          ->get_id_from_link($v['link_attr']['href']);
        $email = $v['content']['Email'];
        $email['id'] = $id;
        if ($return_email && $return_email == $v['content']['Email']['EmailAddress']) {

          // return single email
          return $email;
        }
        $emails[] = $email;
      }
    }
    else {
      $id = $this
        ->get_id_from_link($_emails['link_attr']['href']);
      $email = $_emails['content']['Email'];
      $email['id'] = $id;
      $emails[] = $email;
      if ($return_email && $return_email == $_emails['content']['Email']['EmailAddress']) {

        // return single email
        return $email;
      }
    }
  }
  return $emails;
}