We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

php wrapper - updateContact


php wrapper - updateContact


function updateContact($newmember){
//Create search object and search cc lists for user 
  	   $contacts = new ContactsCollection();
  		$search = $contacts->searchByEmail($newmember['email']);

//Get resources of contact we found
	$contactId = $search[0][0]->getId();
	     		$contact = new Contact();
			//Sadly we must get all lists from account
				$myLists = new ListsCollection();
				$lists = $myLists->getLists();
			//Loop through them
				foreach($lists[0] as $list){
					$name = $list->getName();
				//Find the Correct list	
					if($name == 'ifp members'){
					//Get lists ID and assign it to our contact
					$id = $list->getId();
//Create Collection object and send update request 	
 	$collection = new ContactsCollection();
 	$return = $collection->updateContact($contactId,$contact);
	 echo $return;



ok so this code is a bit messy, but I can't quite seem to get the updateContact function to work. This returns a 400. What are the requirements for a proper contact object to pass to the updateContact function? 


Any comments appreciated! 







I took a look at your code and I believe I found the issue.  Our system will return a 400 error if the XML that is included in the https call has data in certain nodes that it knows is not correct.  This includes StateCode, CountryCode, and PostalCode.  I see that in your code you are using setPostalCode as the email and setStateCode as the zip code.  If you change these calls to point to the correct data, it should allow the update to work.


If you are still running into an issue please let me know and we will continue to troubleshoot to find out what is going on.




Ben Soder

API Support

Benjamin Soder
NOC Analyst
Constant Contact
Developer Portal

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

Visit Page