phpWrapper contact->getLists?

SOLVED
Go to solution
Regular Participant

phpWrapper contact->getLists?

how do I get an array of the current lists a contact is signed up for?  tried:

$lists = $contact->getLists();

which just gave me an empty array...

 

Also, please, where are the docs for this wrapper?

1 ACCEPTED SOLUTION

Hi,

 

You do not need to get the contact ID before listing the contact details.  The listContactDetails function requires the contact object.  Instead of getting the id, you would just do this:

 

<?php
  include_once("ctctWrapper.php");
  $contacts = new ContactsCollection();
  $search = $contacts->searchByEmail('emailaddress@test.com');
  $contact = $search[0][0];
  $contact = $contacts->listContactDetails($contact);
  $contactLists = $contact->getLists();
  print_r ($contactLists);
?>
 

 

This snippet will give you a printed array of lists for the emailaddress@test.com.  If you have any questions please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact

View solution in original post

4 REPLIES 4
Employee

Hello,

 

You can get the lists by pulling the contacts details.  In the phpwrapper you would do a call to the listContactDetails function.  This will list all of the contacts details, which include a field that gives you an array of all the lists the contact is currently on.  You can then call the getLists function on the contact object, and it should return all the lists.

 

If you have any questions, or are still running into an issue, please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Regular Participant

<?php require_once("ctctWrapper.php");?>
<?php
updateContact($myrecordset);
?>
<?php
function updateContact($newmember){
//get the the user id using search by email   	$contacts = new ContactsCollection();
  		$search = $contacts->searchByEmail($newmember['UserEmail']);
		
		
		//print_r($search); works great 


	if($search){
// if $search then get contact id 	$contactId = $search[0][0]->getId();

//this is where I lose it I think 
	$bobbuttons=$contacts->listContactDetails($contactId);
	print_r($bobbuttons);

}

 Sorry, I'm not getting some basic concepts still...

Hi,

 

You do not need to get the contact ID before listing the contact details.  The listContactDetails function requires the contact object.  Instead of getting the id, you would just do this:

 

<?php
  include_once("ctctWrapper.php");
  $contacts = new ContactsCollection();
  $search = $contacts->searchByEmail('emailaddress@test.com');
  $contact = $search[0][0];
  $contact = $contacts->listContactDetails($contact);
  $contactLists = $contact->getLists();
  print_r ($contactLists);
?>
 

 

This snippet will give you a printed array of lists for the emailaddress@test.com.  If you have any questions please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact

View solution in original post

Regular Participant

thank you, good sir...that solved it.

 

Once again...are there any sample files or docs for this wrapper?  Without the docs, it is almost easier to use the long methods...almost.

Developer Portal

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

Visit Page