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--
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,
How would I go about adding the contacts name etc.? Where can I find this information in an easily digestible format?
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,