How to get List id's of lists in which an email already exists

I am working on to integrating the sample code of php with application. Our requirement is to add an email(xyz@abc.com ) into the list A other than that email(xyz@abc.com ) is already existing in B,C,D and E list.

My purpose is to get the list id of B,C,D and E list and add it to atom and make and entry to update the contact.
So I am not getting the way to get the list id of a contact in which that email exists.
If anybody knows how to fetch list id of a contact in it exists, please reply me as soon as possible.

Thanks in advance

You can query a contact using

You can query a contact using the Contacts collection, this will return all the lists the contact is currently on. You can then modify those selections in any way and PUT back an update. This will update the contact with the changed interests.

Here is how to query:

http://api.constantcontact.com/ws/customers/joesflowers/contacts?email=x...

Hope this helps.

Dave B Support Engineer, Constant Contact

Update list with PUT

Does that mean that if I only PUT with just the details of the new list like:
$entry = '<ContactList id="http://api.constantcontact.com/ws/customers/' . CC_USERNAME . '/lists/8">
    <link xmlns="http://www.w3.org/2005/Atom" href="http://api.constantcontact.com/ws/customers/' . CC_USERNAME . '/lists/8" rel="self" />
    <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
    <OptInTime>' . date('Y-m-d\TH:i:s\Z') . '</OptInTime>
</ContactList>';
Would that keep all the current details (previously entered by the contact) and just add this list to it.
I just trying to find a way to just add a list to an xml and not have to get all the details & re PUT them.
Cheers

You would need to put all the

You would need to put all the lists the customer wants to be on in the PUT, otherwise we will overwrite the last list selections with the new ones.  Since you will already need to query Constant Contact to see if the customer exists before updating them, you will be able to get this previous information fairly easily.  It looks like you're using PHP for your language, php does offer XML parsing that will let you pull out the ContactLists nodes and put together an XML document pretty easily so you won't have to completely parse everything.

Dave B Support Engineer, Constant Contact

lets get it right

So to be correct:
1. query the user email
2 if user already subscribed (to another list), get previous list details
3 create a new 'entry' with just details of both new & old list
4 PUT the 'entry'
Would that work? what are the minimum parameters that I have to put in the PUT (user id, ...?)
 

How to get List id's of lists in which an email already exists

============================================================
Following is the XML feed which i am getting from the api call with contact id
http://api.constantcontact.com/ws/customers/veerpartap/contacts?email=sagarsidan%40gmail.com
============================================================
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/veerpartap/contacts</id> 
  <link href="http://api.constantcontact.com/ws/customers/veerpartap/contacts"/>
  <link rel="self" href="http://api.constantcontact.com/ws/customers/veerpartap/contacts"/>
  <author>
    <name>veerpartap</name>
  </author>
  <updated>2009-06-19T05:13:06.061Z</updated>
  <link rel="first" href="/ws/customers/veerpartap/contacts"/>
  <link rel="current" href="/ws/customers/veerpartap/contacts"/>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/contacts/69"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/contacts/69</id>   
    <updated>2009-06-19T05:13:06.085Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contact id="http://api.constantcontact.com/ws/customers/veerpartap/contacts/69" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <status>Unconfirmed</status>
        <emailaddress>sagarsidan@gmail.com</emailaddress>
        <emailtype>HTML</emailtype>
        <name>sidan, sagar</name>
        <optintime>2009-06-12T14:16:24.207Z</optintime>
        <optinsource>ACTION_BY_CONTACT</optinsource>
        <confirmed>true</confirmed>
        <inserttime>2009-06-12T14:16:24.207Z</inserttime>
      </contact>
    </content>
  </entry>
</feed>
============================================================

===========================================================
With an api call i can fetch all the lists id.
[ But as per my requirement i need to create a new 'entry'
with just details of both new & old list for which I need list id of those list in which that email
exists    ]
http://api.constantcontact.com/ws/customers/veerpartap/lists
=============================================================

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/veerpartap/lists</id> 
  <link href="http://api.constantcontact.com/ws/customers/veerpartap/lists"/>
  <link rel="self" href="http://api.constantcontact.com/ws/customers/veerpartap/lists"/>
  <author>
    <name>veerpartap</name>
  </author>
  <updated>2009-06-19T05:41:29.252Z</updated>
  <link rel="first" href="/ws/customers/veerpartap/lists"/>
  <link rel="current" href="/ws/customers/veerpartap/lists"/>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/active"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/active</id>   
    <updated>2009-06-19T05:41:29.258Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/active" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <name>Active</name>
        <shortname>Active</shortname>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/do-not-mail"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/do-not-mail</id>   
    <updated>2009-06-19T05:41:29.258Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/do-not-mail" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <name>Do Not Mail</name>
        <shortname>Do Not Mail</shortname>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/removed"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/removed</id>   
    <updated>2009-06-19T05:41:29.258Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/removed" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <name>Removed</name>
        <shortname>Removed</shortname>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/5"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/5</id>   
    <updated>2009-06-19T05:41:29.259Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/5" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <optindefault>false</optindefault>
        <name>Enemies</name>
        <shortname>Enemies</shortname>
        <sortorder>4</sortorder>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/6"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/6</id>   
    <updated>2009-06-19T05:41:29.259Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/6" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <optindefault>false</optindefault>
        <name>Relatives</name>
        <shortname>Relatives</shortname>
        <sortorder>5</sortorder>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/3"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/3</id>   
    <updated>2009-06-19T05:41:29.259Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/3" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <optindefault>false</optindefault>
        <name>Friends</name>
        <shortname>Friends</shortname>
        <sortorder>3</sortorder>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/2"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/2</id>   
    <updated>2009-06-19T05:41:29.259Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/2" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <optindefault>false</optindefault>
        <name>LJP</name>
        <shortname>LJP</shortname>
        <sortorder>2</sortorder>
      </contactlist>
    </content>
  </entry>
  <entry>
    <link rel="edit" href="/ws/customers/veerpartap/lists/1"/>
    <id>http://api.constantcontact.com/ws/customers/veerpartap/lists/1</id>   
    <updated>2009-06-19T05:41:29.260Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/1" xmlns="http://ws.constantcontact.com/ns/1.0/">
        <optindefault>true</optindefault>
        <name>General Interest</name>
        <shortname>General Interest</shortname>
        <sortorder>1</sortorder>
      </contactlist>
    </content>
  </entry>
</feed>
==============================================================

=================================================================
Following is the xml entry of ATOM which is created  with both the New list in which the user is about to add
and the Old list in which that user already exists.
=================================================================
<entry xmlns="http://www.w3.org/2005/Atom">
    <id>http://api.constantcontact.com/ws/customers/veerpartap/contacts/69</id>
    <updated>2009-06-19T16:31:17+01:00</updated>
    <author><name>CTCT Samples</name></author>
    <id>urn:uuid:E8553C09F4xcvxCCC53F481214230867087</id>
    <summary type="text">Customer document</summary>
    <content type="application/vnd.ctct+xml">
        <contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/veerpartap/contacts/69">
            Customer document
            <emailaddress>sagarsidan@gmail.com</emailaddress>
            <firstname>sagar</firstname>
            <lastname>sidan</lastname>
            <middlename/>
            <companyname/>
            <jobtitle/>
            <optinsource>ACTION_BY_CUSTOMER</optinsource>
            <contactlists>
                <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/1">
                <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/2">
                <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/3">
                <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/6">
                <contactlist id="http://api.constantcontact.com/ws/customers/veerpartap/lists/5"/>
                </contactlist>
                </contactlist>
                </contactlist>
                </contactlist>
            </contactlists>
        </contact>
    </content>
</entry>
==================================================================