Need a Sample of Query to the Contacts Collection using Email Address

Highlighted
Solution Provider

Need a Sample of Query to the Contacts Collection using Email Address

I have been through the entire support site and can not seem to find a php sample that shows how to query the contacts collection for specific email address. I need to be able to find out if a contact exists before trying to add the contact to a list. If the contact is new then the add contact php sample code works fine. But it the contact is already in the system, then I need the contact id in order to add the email to a special list.

We have added a form to the public website to allow customers to sign up for contest.

Any help?
Thanks
2 REPLIES 2
Moderator

If you look at this page, it

If you look at this page, it gives you the URI syntax for querying the contacts collection. Hope this helps!
Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Participant

Need a concrete sample

Hi there,
I a in the same situation.
I got two lists, and if a contact is new it does add the details to the one list. But if the contact is in the other list, it says that the email address is already there.

This is some process that t I found in the forum: (Tom Mignosa, Product Manager, Constant Contact)
Use the Contacts Resource to find out if the contact already exists in the database (see "Querying the Contacts Collection" section of that page).
If the contact already exists, the "Query by Contact" will return a link to the Contact Details (ie. a URI). GET the contact details for the contact, which will include the list association for that contact. Update the returned XML as needed and PUT the contact XML back.
If the contact does not exist, the Query by Contact will return an empty set (a XML stream with no tags). Construct the entry to create the contact, including list associations, and POST the XML back.

unfortunately, I don't know how to integrate that within my existing php code.
The samples (in php), on the page that you gave above, are not helpful for that particular matter.

Could someone help me out ? some php samples?

Cheers
Developer Portal

View API documentation, code samples, get your API key.