cancel
Showing results for 
Search instead for 
Did you mean: 
Happy Turkey Day! In recognition of Thanksgiving our Support office will be closed Thursday (11/23). We will be open Friday (11/24) for limited hours (10:00am - 6pm ET) and will be back to normal hours on Monday (11/27).

Can't get ACTION_BY_VISITOR working with PHP API

SOLVED
Occasional Participant

Can't get ACTION_BY_VISITOR working with PHP API

Goal: to take contact information that is POST'ed to my script and add-or-update the contact in ConstantContact.   Reason for using an API is because we're doing other things with that contact info too (adding to our custom CRM, emailing ourselves a notification, etc.)

 

So I optained an API key and Access Token, downloaded the PHP SDK from https://github.com/constantcontact/php-sdk , uploaded the PHP files to my server and started playing with the addOrUpdateContact.php sample.

 

Using this line in the code:

            $returnContact = $cc->contactService->addContact(ACCESS_TOKEN, $contact);

 

things seem to work, and here is the result:

 

Ctct\Components\Contacts\Contact Object
(
    [id] => 1071913118
    [status] => ACTIVE
    [first_name] => Scott
    [last_name] => Wang
    [confirmed] => 
    [source] => Site Owner
    [email_addresses] => Array
        (
            [0] => Ctct\Components\Contacts\EmailAddress Object
                (
                    [id] => 7c176990-adaf-11e6-afb1-782bcb740129
                    [status] => ACTIVE
                    [confirm_status] => NO_CONFIRMATION_REQUIRED
                    [opt_in_source] => ACTION_BY_OWNER
                    [opt_in_date] => 2016-11-18T16:53:09.000Z
                    [opt_out_date] => 
                    [email_address] => *********
                )

        )

(etc etc)

 

The problem is the "ACTION_BY_OWNER" part doesn't trigger welcome emails or allow a visitor to re-opt-in.

 

So I tried this (as instructed by the sample file):

 

$returnContact = $cc->contactService->addContact(ACCESS_TOKEN, $contact, true);

 

 

But after submitting the form, I simply get a blank white page (and the contact doesn't get updated or added at all).

 

So I googled (A LOT) and found this suggestion here on the forum:

$returnContact = $cc->contactService->addContact(ACCESS_TOKEN, $contact, array("action_by" => "ACTION_BY_VISITOR"));

Now, after submitting the sample form, the page loads but it shows the same result with [opt_in_source] => ACTION_BY_OWNER  as if it ignored the ACTION_BY_VISITOR setting.

 

I've found lots of websites that suggest adding this setting to the URL that the request is posted to but there is no such setting that I can find in the PHP API that I downloaded.

 

This seems way too complicated.  Is there a different type of API I should be using?  I just want a script that will submit contact details and have CC update-or-add them.  I feel like I'm very close if I could get this one working.

 

-Scott

 

 

 

6 REPLIES
Moderator

Re: Can't get ACTION_BY_VISITOR working with PHP API

Hi @ScottW982,

 

You are very close. I believe this will work much better for you.

 

$params = ["action_by"=>"ACTION_BY_OWNER"];
            
$returnContact = $cc->contactService->addContact(ACCESS_TOKEN, $contact, $params);

Regards,
Jimmy D.
Tier II API Support Engineer
Occasional Participant

Re: Can't get ACTION_BY_VISITOR working with PHP API

Hi @Jimmy_D, thanks for the reply but unfortunately no luck.

Using this in both the new-contact and update-contact sections of addOrUpdateContact.php:

$params = ["action_by"=>"ACTION_BY_VISITOR"];
$returnContact = $cc->contactService->addContact(ACCESS_TOKEN, $contact, $params);

Still results in ACTION_BY_OWNER in the result:

Ctct\Components\Contacts\Contact Object
(
    [id] => 1071913118
    [status] => ACTIVE
    [first_name] => Scott
    [last_name] => Wang
    [confirmed] => 
    [source] => Site Owner
    [email_addresses] => Array
        (
            [0] => Ctct\Components\Contacts\EmailAddress Object
                (
                    [id] => 7c176990-adaf-11e6-afb1-782bcb740129
                    [status] => ACTIVE
                    [confirm_status] => NO_CONFIRMATION_REQUIRED
                    [opt_in_source] => ACTION_BY_OWNER
                    [opt_in_date] => 2016-11-18T16:53:09.000Z
                    [opt_out_date] => 
                    [email_address] => ******************
                )

        )

    [prefix_name] => 
    [job_title] => 
    [addresses] => Array
        (
        )

    [notes] => Array
        (
        )

    [company_name] => 2465465465
    [home_phone] => 
    [work_phone] => 
    [cell_phone] => ****************
    [fax] => 
    [custom_fields] => Array
        (
        )

    [lists] => Array
        (
            [0] => Ctct\Components\Contacts\ContactList Object
                (
                    [id] => 55
                    [name] => 
                    [status] => ACTIVE
                    [contact_count] => 
                    [created_date] => 
                    [modified_date] => 
                )

        )

    [created_date] => 2016-11-18T16:53:09.000Z
    [modified_date] => 2017-11-06T21:03:36.000Z
    [source_details] => 
)
Moderator

Re: Can't get ACTION_BY_VISITOR working with PHP API

Hi @ScottW982,

 

Let me see why this isn't working and I'll get back with you.


Regards,
Jimmy D.
Tier II API Support Engineer
Occasional Participant

Re: Can't get ACTION_BY_VISITOR working with PHP API

I played around with this some more and found something odd.  I've been using an old email address (that used to be in CC but was deleted by myself during this testing), and the result was always "ACTION_BY_OWNER".

 

But if I use a brand new email address that has never been in CC, now I'm seeing "ACTION_BY_VISITOR"!

 

 

If someone opts in through this form, they should get the welcome email and be re-added to the autoresponder series, but that doesn't happen when I use my old email address.  

 

Does this shed new light on the issue?

 

-Scott

Moderator

Re: Can't get ACTION_BY_VISITOR working with PHP API

Hello Scott,

 

When looking at an individual contact, the opt-in source will be the source of the contact when it was originally created. So if you previously had added a contact yourself, they would show as by owner even if they had been deleted and re-added as action_by_visitor. 

 

There are several instances where a Welcome email would not send. Welcome emails are sent to "new" contacts on the account. That means contacts who have not existed, or were in a removed state (deleted from the website UI). If a contact is active on the account, they would not be sent a welcome email upon using a signup form. They also would not be sent one if they are added as action_by_owner. And if you have an autoresponder series associated with the list they are being added to, the welcome email is not sent and defers to the Autoresponder campaign.

 

Regardless of any of the above, they would be added to any list associated with the form, so if you have a standard autoresponder campaign associated with that list, signups that are new to that list would queue for the series. If they have been sent the email already, however, they will not be sent the series again.

 

Please let me know if you have any other questions!

 

Sincerely,
David B.
Tier II API Support Engineer

Highlighted
Occasional Participant

Re: Can't get ACTION_BY_VISITOR working with PHP API

Thanks David!  Now that I know this is how it works, it looks like my script is working perfectly. :)

 

-Scott

 

Still need help?
You can post a new message in the Community or find us on Twitter Mon-Fri 8am - 8pm ET. We've got real people waiting to help you out. Click below to start a conversation!
Loading script asynchronously