function cc::query_contacts in Constant Contact 7.3
Same name and namespace in other branches
- 6.3 class.cc.php \cc::query_contacts()
- 6.2 class.cc.php \cc::query_contacts()
Queries the API for contacts with a similar email address to the input.
@access public
File
- ./
class.cc.php, line 909 - Constant Contact PHP Class
Class
- cc
- @file Constant Contact PHP Class
Code
function query_contacts($email) {
$xml = $this
->load_url('contacts?email=' . strtolower(urlencode($email)));
if (!$xml) {
return FALSE;
}
$contact = FALSE;
// We need a duplicates clean up routine here as there should be
// only one id for each distinct emaill address
if (isset($xml['feed']['entry']) && array_key_exists('1', $xml['feed']['entry'])) {
foreach ($xml['feed']['entry'] as $key => $entry) {
if (intval($key) > 0) {
$dupe_id = $this
->get_id_from_link($entry['link_attr']['href']);
$this
->delete_contact($dupe_id);
unset($xml['feed']['entry'][$key]);
}
}
$xml['feed']['entry'] = $xml['feed']['entry'][0];
}
$_contact = isset($xml['feed']['entry']) ? $xml['feed']['entry'] : FALSE;
// Parse into nicer array.
if (is_array($_contact)) {
$id = $this
->get_id_from_link($_contact['link_attr']['href']);
$contact = $_contact['content']['Contact'];
$contact['id'] = $id;
}
return $contact;
}