API for Php version 5.2

MarkC784
Regular Participant

API for Php version 5.2

Hi,

 

Is there anyone knows where can i find the sample codes/api that is working on php version 5.2? The api that i downloaded from github has the minimum requirements of php 5.3. Anyone, please?

11 REPLIES 11
Elijah_G
Member

Hello Mark,

 

Depending on what you need to accomplish, we have a few options available for you. The first option that we have would be to use our V1 API and V1 PHP wrapper which works with any version of PHP5+. However, if you choose to follow this road it is important to note that our V1 API is deprecated and likely to be discontinued in late 2014. If you choose this route, you can find our Docs for V1 and a link to the PHP library here: http://community.constantcontact.com/t5/Documentation/V1-XML-API-Documentation/ba-p/25125

 

Another option that I can offer for a simple task is to provide a sample code of how to use cURL without a specific wrapper to communicate with the API for things such as adding a contact.

 

Please let me know what you're interested in, and I will be happy to provide some resources!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
MarkC784
Regular Participant

Hi Elijah_G,

 

Thank you so much for your response. I was somehow getting hope to complete this task. 

I would prefer the 2nd option, sample working code of how to use CURL without a specific wrapper to communicate with API. Do you think it would work on creating a simple newsletter and removing contact from contact list?

MarkC784
Regular Participant

Is there anyone knows a solution for this?

We will be able to post a cURL example later today for you.  It's important to note that PHP version 5.2 is no longer supported and is considered an insecure version of PHP with no new security fixes being released (see version support level here: http://en.wikipedia.org/wiki/PHP).  Generally, we recommend that you make sure you are upgrading your PHP versions to the latest supported versions to keep up with security updates which is why we now support PHP 5.3 (the lowest actively supported version of PHP).

 

Update: I noticed that 5.3 is now in a security fix only support state now.  The wrapper works fully in 5.4 and 5.5, both of which are fully supported for bug and security fixes. 

Dave Berard
Senior Product Manager, Constant Contact

Hello Mark,

 

Here's the sample I mentioned: https://github.com/kramerg/ctct_php_sample

 

This is a very basic sample and shows the concept of using a few simple API calls. For detailed information about the API endpoints and what information is required to use them, you can read more here: http://developer.constantcontact.com/docs/developer-guides/api-documentation-index.html

 

If you have questions about how to use pieces of our API, the docs are a great place to start. If you get stuck, please feel free to post here in the forums for assistance!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
MarkC784
Regular Participant

Thank you for the example. May I know what does this error mean {"curl_error":"Error 0 "} ?

I got that error on MakeRequest function

Error 0 means the request is successful and to proceed.  You can see the full list of cURL errors here: http://curl.haxx.se/libcurl/c/libcurl-errors.html

Dave Berard
Senior Product Manager, Constant Contact
MarkC784
Regular Participant

Thank you for that. I am sorry for having many questions, i am not quite familiar with the structure.

Do you have a guide on how to create a newsletter in your user interface?

Hello,

 

For information about creating a campaign through our UI, you can find that here: http://knowledgebase.constantcontact.com/articles/KnowledgeBase/5557-create-an-email-campaign

 

Also it is worth mentioning that for questions that are not related to our APIs you can contact our general support team who may be able to respond to your inquiries in a more timely manner. You can find information on how to contact them listed here: https://ui.constantcontact.com/support/index.jsp

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
MarkC784
Regular Participant

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

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
Developer Portal

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

Visit Page