Using Php wrapper

Highlighted

Using Php wrapper

I need some help in using the PhpWrapper class, mainly the Contact and the ContactsCollection class.

I have a contact list called "Xyz", which I created manually.

Now, using the Php wrapper class, I want to add an email address to that list.

 

I need to know:

a) Which ones are the mandatory fields?

b) What does $contact->serLink() do?

c) What about $contacts->setLists()

etc

etc

 

Could you please direct me to a sample code which uses the ctctWrapper/ctctWrapper.php . Using the Php form example is no good, and no offense, please don't direct me to the API documentation.

 

Thanks

 

--Anurag--

3 REPLIES 3
Highlighted
CTCT Employee

Re: Using Php wrapper

Hey Anurag,

 

This would be an example of adding a contact to your account with comments to explain how each part functions.

 

<?php

// Include the header at the top 
include_once('ctctWrapper.php');

// Connect to the Contacts URI
$data = new ContactsCollection();

// Create a new Contact Object
$contact = new Contact();

// This Contact's email address is...
$contact->setEmailAddress("newContact222@test.com");

// This Contact will belong to this list - Replace where {username} is with your username
// Also remember to set listID to list number such as 1, which is typically your general interest
$contact->setLists("http://api.constantcontact.com/ws/customers/{username}/lists/{listID}"); // create the contact with the paremeters of the previous information $contacts = $data->createContact($contact); // You can print the data to see if there is an error anywhere in your submission // will print out a 400 if there is an error and a 200 if it is successful
// print_r($contacts);

// will print out your XML that will be submitted. Only the entry's you provide will be listed
// print_r($contact); ?>

 Please let me know this helps.

 

Thanks,

Ryan Davis
Quality Engineer
Highlighted
Occasional Contributor

Re: Using Php wrapper

How would I go about adding the contacts name etc.?  Where can I find this information in an easily digestible format?

Highlighted
CTCT Employee

Re: Using Php wrapper

Hey,

 

Our new PHP wrapper can be found here and has a folder with examples, specifically Adding Contacts.

After creating the object, you would assign it a "firstName".

 

$myContact = new Contact();
$myContact->firstName = "My First Name";

 

If you need assistance with this wrapper, please let us know specifically what issues you are having and we'll work with you towards a solution.

 

Thanks,

Andrew Weber
Associate Product Manager for EventSpot
Developer Portal

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

Constant Contact would like to hear from you

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured