function cc::get_list_members in Constant Contact 7.3
Same name and namespace in other branches
- 6.3 class.cc.php \cc::get_list_members()
- 6.2 class.cc.php \cc::get_list_members()
Gets the members (contacts) in a specific contact list.
Supports paging of the results.
@access public
File
- ./
class.cc.php, line 609 - Constant Contact PHP Class
Class
- cc
- @file Constant Contact PHP Class
Code
function get_list_members($listid, $action = 'members') {
$xml = $this
->load_url("lists/{$listid}/{$action}");
if (!$xml) {
return FALSE;
}
// Parse into nicer array.
$contacts = array();
$_members = isset($xml['feed']['entry']) ? $xml['feed']['entry'] : FALSE;
if (isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'first') {
$this->member_meta_data->first_page = $this
->get_id_from_link($xml['feed']['link']['2_attr']['href']);
$this->member_meta_data->current_page = $this
->get_id_from_link($xml['feed']['link']['3_attr']['href']);
$this->member_meta_data->next_page = '';
}
elseif (isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'next') {
$this->member_meta_data->next_page = $this
->get_id_from_link($xml['feed']['link']['2_attr']['href']);
$this->member_meta_data->current_page = $this
->get_id_from_link($xml['feed']['link']['3_attr']['href']);
$this->member_meta_data->first_page = $this
->get_id_from_link($xml['feed']['link']['4_attr']['href']);
}
else {
$this->member_meta_data->next_page = NULL;
$this->member_meta_data->current_page = NULL;
$this->member_meta_data->first_page = NULL;
}
if (is_array($_members)) {
if (isset($_members[0]['link_attr']['href'])) {
foreach ($_members as $k => $v) {
$EmailAddress = $v['content']['ContactListMember']['EmailAddress'];
$Name = $v['content']['ContactListMember']['Name'];
$id = $this
->get_id_from_link($v['link_attr']['href']);
$contact = array(
'id' => $id,
'EmailAddress' => $EmailAddress,
'Name' => $Name,
);
$contacts[] = $contact;
}
}
else {
$EmailAddress = $_members['content']['ContactListMember']['EmailAddress'];
$Name = $_members['content']['ContactListMember']['Name'];
$id = $this
->get_id_from_link($_members['link_attr']['href']);
$contact = array(
'id' => $id,
'EmailAddress' => $EmailAddress,
'Name' => $Name,
);
$contacts[] = $contact;
}
}
return $contacts;
}