function cc::get_contacts in Constant Contact 6.2
Same name and namespace in other branches
- 6.3 class.cc.php \cc::get_contacts()
- 7.3 class.cc.php \cc::get_contacts()
* Gets all contacts and allows paging of the results * * @access public
File
- ./
class.cc.php, line 676
Class
- cc
- @file
Code
function get_contacts($action = 'contacts') {
$xml = $this
->load_url($action);
if (!$xml) {
return false;
}
// parse into nicer array
$contacts = array();
$_contacts = isset($xml['feed']['entry']) ? $xml['feed']['entry'] : false;
if (isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'first') {
$this->contact_meta_data->first_page = $this
->get_id_from_link($xml['feed']['link']['2_attr']['href']);
$this->contact_meta_data->current_page = $this
->get_id_from_link($xml['feed']['link']['3_attr']['href']);
$this->contact_meta_data->next_page = '';
}
elseif (isset($xml['feed']['link']['2_attr']['rel']) && $xml['feed']['link']['2_attr']['rel'] == 'next') {
$this->contact_meta_data->next_page = $this
->get_id_from_link($xml['feed']['link']['2_attr']['href']);
$this->contact_meta_data->current_page = $this
->get_id_from_link($xml['feed']['link']['3_attr']['href']);
$this->contact_meta_data->first_page = $this
->get_id_from_link($xml['feed']['link']['4_attr']['href']);
}
if (is_array($_contacts)) {
if (isset($_contacts[0]['link_attr']['href'])) {
foreach ($_contacts as $k => $v) {
$id = $this
->get_id_from_link($v['link_attr']['href']);
$contact = $v['content']['Contact'];
$contact['id'] = $id;
$contacts[] = $contact;
}
}
else {
$id = $this
->get_id_from_link($_contacts['link_attr']['href']);
$contact = $_contacts['content']['Contact'];
$contact['id'] = $id;
$contacts[] = $contact;
}
}
return $contacts;
}