ActiveCampaign / activecampaign-api-php

MIT License
115 stars 76 forks source link

Create contact with Address and Address2 values #113

Closed DonnieM77 closed 4 years ago

DonnieM77 commented 4 years ago

I've tried a dozen different things, but seem completely unable to update either of these fields. I can stuff the data into any other field and can't seem to pass anything into address, or address2

` //send core info $contact = array( 'email' => $user_email, 'first_name' => $first_name, 'last_name' => $last_name, 'phone' => $Phone, "p[{$ac_list_id}]" => $ac_list_id, "status[{$ac_list_id}]" => 1, 'tags' => $default_tags ); $contact_sync = $connect_wptoac_sync->api('contact/sync', $contact);

//send Address
$contact = array(
        'email'                 => $user_email,
        'address'               => $Address
);
$contact_sync = $connect_wptoac_sync->api('contact/sync', $contact);

//send Address2
$contact = array(
        'email'                 => $user_email,
        'address2'              => $Address2
);
$contact_sync = $connect_wptoac_sync->api('contact/sync', $contact);

//Send  City DM 4.16.20
$contact = array(
        'email'                 => $user_email,
        'field[%CITY%]'=> $City
);
$contact_sync = $connect_wptoac_sync->api('contact/sync', $contact);

//Send State DM 4.16.20
$contact = array(
        'email'                 => $user_email,
        'field[%STATE%]'=> $State
);
$contact_sync = $connect_wptoac_sync->api('contact/sync', $contact);

//Send Zip DM 4.16.20
$contact = array(
    'email'                 => $user_email,
        'field[%ZIP_POSTAL_CODE%]'  => $Zip
);
$contact_sync = $connect_wptoac_sync->api('contact/sync', $contact);

`

the user is being created with first name, last name, email, phone, city, state, zip, and country populated with the proper info. For the life of me, I can't get address or address2 to take any data.

I verified that the fields are connected to the list. But, I've even tried another list that the fields show as being connected to. I have an integration through GoToWebinar that's sending data to address and addresse2 among other fields. I've passed the address data to state just to be sure I have the data, I do.

Totally confused.

DonnieM77 commented 4 years ago

The answer: $contact[urlencode('field[%ADDRESS%]')] = 'value'; urlencode( ) not only solved the issue with Address and Address2, but also solved the issue of sending all the custom fields in a single array and a single contact/sync call.

Peppe87 commented 4 years ago

Thanks for the info. It would be great to add that to the examples.