cancel
Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

API for Php version 5.2

Occasional Participant

Re: API for Php version 5.2

Thank you elijah. You are such a big help to me who is newbie. 

Regarding the api that uses curl, the one you gave to me, I checked on it if there is any function related to GET ALL THE CONTACTS FROM SPECIFIC LIST? I can't seem to find it on the given example. So, I tried this one

function getContacts($list_id) {
return json_decode( MakeRequest("https://api.constantcontact.com/v2/contacts/$list_id?api_key="._apiKey,"GET"));
}

It didn't work. Can you help me please

Highlighted
Honored Contributor

Re: API for Php version 5.2

Hello Mark,

 

You've got the right idea with using the list ID, but we actually have a specific API endpoint that is used for lists. You can find the specifications for that here: http://developer.constantcontact.com/docs/contact-list-api/contactlist-membership-collection.html

 

Based on the specifications on that link, the format for your URL will be like this:

https://api.constantcontact.com/v2/lists/{listId}/contacts?limit={1-500}&api_key={APIKey}

 

So if I take that format and use it in the code function, it comes out like this:

function getContacts($list_id, $limit) {
return json_decode( MakeRequest("https://api.constantcontact.com/v2/lists/$list_id/contacts/?limit=$limit&api_key="._apiKey,"GET"));
}

 

One other important thing to note is that if the list has more than $limit contacts, the system will return a pagination URL that you can use to fetch the next page of results. If youlook at the example response in the documentation I linked above, you can see an example of how that link is delievered.

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer