You are here

function cc::update_list in Constant Contact 7.3

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

Updates an existing contact list.

@access public

File

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

Class

cc
@file Constant Contact PHP Class

Code

function update_list($id, $name, $default = "false", $sort_order = 99) {

  // Build the XML put data.
  $url = $this
    ->get_list_url($id);
  $xml_data = '
<entry xmlns="http://www.w3.org/2005/Atom">
  <id>' . $url . '</id>
  <title type="text">' . $name . '</title>
  <author />
  <updated>2008-04-16T18:39:35.710Z</updated>
  <content type="application/vnd.ctct+xml">
    <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/"
        id="' . $url . '">
      <OptInDefault>' . $default . '</OptInDefault>
      <Name>' . $name . '</Name>
      <ShortName>' . $name . '</ShortName>
      <SortOrder>' . $sort_order . '</SortOrder>
    </ContactList>
  </content>
  <link href="/ws/customers/' . $this->api_username . '/lists/' . $id . '" rel="update" />
</entry>
';
  $this
    ->http_set_content_type('application/atom+xml');
  $xml = $this
    ->load_url("lists/{$id}", 'put', $xml_data, 204);
  if (intval($this->http_response_code) === 204) {
    return TRUE;
  }
  return FALSE;
}