function cc::update_contact in Constant Contact 6.2
Same name and namespace in other branches
- 6.3 class.cc.php \cc::update_contact()
- 7.3 class.cc.php \cc::update_contact()
* Updates a contact * * @access public
File
- ./
class.cc.php, line 618
Class
- cc
- @file
Code
function update_contact($id, $email, $lists = array(), $additional_fields = array()) {
// build the XML put data
$_url = str_replace('https:', 'http:', $this->api_url . "contacts");
$url = "{$_url}/{$id}";
$xml_data = '<entry xmlns="http://www.w3.org/2005/Atom">
<id>' . $url . '</id>
<title type="text">Contact: ' . $email . '</title>
<updated>2008-04-25T19:29:06.096Z</updated>
<author></author>
<content type="application/vnd.ctct+xml">
<Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="' . $url . '">
<EmailAddress>' . $email . '</EmailAddress>
<OptInSource>' . $this->action_type . '</OptInSource>
';
if ($additional_fields) {
foreach ($additional_fields as $field => $value) {
$xml_data .= "<{$field}>{$value}</{$field}>\n";
}
}
$xml_data .= "<ContactLists>\n";
if ($lists) {
if (is_array($lists)) {
foreach ($lists as $k => $list_id) {
$xml_data .= '<ContactList id="' . $this
->get_list_url($list_id) . '"></ContactList>';
}
}
else {
$xml_data .= '<ContactList id="' . $this
->get_list_url($list_id) . '"></ContactList>';
}
}
$xml_data .= "</ContactLists>\n";
$xml_data .= '
</Contact>
</content>
</entry>
';
$this
->http_set_content_type('application/atom+xml');
$this
->load_url("contacts/{$id}", 'put', $xml_data, 204);
if (intval($this->http_response_code) === 204) {
return true;
}
return false;
}