You are here

function cc::get_contact in Constant Contact 7.3

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

Gets a specific contact's details.

@access public

File

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

Class

cc
@file Constant Contact PHP Class

Code

function get_contact($id) {
  $xml = $this
    ->load_url("contacts/{$id}");
  if (!$xml) {
    return FALSE;
  }
  $contact = FALSE;
  $_contact = isset($xml['entry']) ? $xml['entry'] : FALSE;

  // parse into nicer array
  if (is_array($_contact)) {
    $id = $this
      ->get_id_from_link($_contact['link_attr']['href']);
    $contact = $_contact['content']['Contact'];
    if (isset($_contact['content']['Contact']['ContactLists']['ContactList'])) {
      $_lists = $_contact['content']['Contact']['ContactLists']['ContactList'];
      unset($_lists['0_attr']);
      unset($_lists['ContactList_attr']);
    }
    else {
      $_lists = FALSE;
    }

    // get lists
    $lists = array();
    if (is_array($_lists) && count($_lists) > 0) {
      unset($_lists['id']);
      if (isset($_lists['link_attr']['href'])) {
        $list_id = $this
          ->get_id_from_link($_lists['link_attr']['href']);
        $lists[$list_id] = $list_id;
      }
      else {
        foreach ($_lists as $k => $v) {
          if (isset($v['link_attr']['href'])) {
            $list_id = $this
              ->get_id_from_link($v['link_attr']['href']);
            $lists[$list_id] = $list_id;
          }
        }
      }
      unset($contact['ContactLists']);
    }
    $contact['lists'] = $lists;
    $contact['id'] = $id;
  }
  return $contact;
}