v2 Adds contact but not address

Occasional Participant

v2 Adds contact but not address

When I try to add a contact it adds it but does not add the address. I've made sure it's set to Personal but my output always comes up blank for the address. I just need to add the city and state. Here is what I have.

 

use Ctct\ConstantContact;
use Ctct\Components\Contacts\Contact;
use Ctct\Components\Contacts\Address;
use Ctct\Exceptions\CtctException;

 

$contact = new Contact();
$contact->addEmail($email);
$contact->addList('2087834845');
$contact->first_name = $fname;
$contact->last_name = $lname;
   
   $address = new Address();
   $address->address_type = "PERSONAL";
   $address->city = "Sioux Falls";
   $address->state_code = "SD";
   $contact->addAddress($address);

3 REPLIES 3
Moderator

Hello,

 

Thank you for reaching out to Constant Contact API Developer Support.

 

Would you be able to verify that once you have added the address to the $contact object that it is added correctly?

 

Also, I'm wondering if manually setting the address might have a different outcome. E.g.:

$contact->addresses[] = $address;

 

Regards,
David B.
Tier II API Support Engineer

Occasional Participant

Hi David,

 

Thanks for getting back to me. I tried manually setting the address and this is what I get for the $contact object.

 

Ctct\Components\Contacts\Contact Object ( [id] => [status] => [first_name] => Adrian [last_name] => Ilchuk [confirmed] => [source] => [email_addresses] => Array ( [0] => Ctct\Components\Contacts\EmailAddress Object ( [id] => [status] => [confirm_status] => [opt_in_source] => [opt_in_date] => [opt_out_date] => [email_address] => ailchuk@acce-online.com ) ) [prefix_name] => [job_title] => [addresses] => Array ( [0] => Ctct\Components\Contacts\Address Object ( [id] => [line1] => [line2] => [line3] => [city] => Sioux Falls [address_type] => PERSONAL [state_code] => SD [state] => [country_code] => [postal_code] => [sub_postal_code] => ) ) [notes] => Array ( ) [company_name] => [home_phone] => [work_phone] => [cell_phone] => [fax] => [custom_fields] => Array ( ) [lists] => Array ( [0] => Ctct\Components\Contacts\ContactList Object ( [id] => 2087834845 [name] => [status] => [contact_count] => [created_date] => [modified_date] => ) ) [created_date] => [modified_date] => [source_details] => )

 

It looks like it's all in there however when I go to view my contacts I see Adrian Ilchuk listed but the city and state are still blank.

Hello,

 

I'd like to look into this specific contact. Please email us at webservices@constantcontact.com and include the following:

  • A code sample of how you are building this contact object
  • The username of the Constant Contact account you are working with

This way I can troubleshoot in more detail.


Regards,
David B.
Tier II API Support Engineer

Developer Portal

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

Visit Page