Arriving at the Constant Contact opt in registration via a PHP

Highlighted
Occasional Participant

Arriving at the Constant Contact opt in registration via a PHP

Hi guys! My client (JW Secure) has asked me to "merge" their Constant Contact sign up with another contact form, so that folks send messages to the client but are also given the option to sign up for the Constant Contact newsletter.

 

You can see the test page here: http://www.jwsecure.com/test.html

 

Long story short, since we're doing more than one action, I am now needing to post the "http://visitor.r20.constantcontact.com/d.jsp" action & values via a client's PHP file instead of the default Constant Contact HTML form below:

 

<form name="ccoptin" action="http://visitor.r20.constantcontact.com/d.jsp" target="_blank" method="post">
<input type="hidden" name="llr" value="z4u4kndab">
<input type="hidden" name="m" value="{Redacted}">
<input type="hidden" name="p" value="oi">
Email: <input type="text" name="ea" size="20" value="">
<input type="submit" name="go" value="Go" class="submit">
</form>

 

I've tried collecting the hidden values as an array and using cURL to post the variables to CC, but it just hangs on the PHP page. After reading up on the forums, I'm now under the impression that cURL won't work with CC, but I'm not sure what the ideal alternative is. I keep getting errors when I try to be creative with the code. Help!

 

I'm sure you guys have been asked this before: What code can we put in the PHP so that the variables are sent and folks arrive at the Constant Contact sign up?

 

Thank you in advance for your expertise/ advice.

 

All the best,

Barry

Tags (1)
6 REPLIES 6
Highlighted
Honored Contributor

Re: Arriving at the Constant Contact opt in registration via a PHP

Hello Barry,

 

When you are working with the Constant Contact JMML form for which you have included the HTML code here, that form posts to a second confirmation form which is normally opened in the same page or as a popup. Because of this, simply doing a CURL post to this page will not fully subscribe a contact.

 

If you are looking for a one-step signup process, you would need to go through our API for that. The easiest way to do this would be to create a free mashery account to get an API key, and then use our PHP wrapper to connect. In addition, the PHP wrapper includes an example of how to add a contact through the API. you can find more information below.

 

Developer Website: http://developer.constantcontact.com/

Mashery (API key Creation): https://constantcontact.mashery.com/

PHP Wrapper: https://github.com/constantcontact/php-sdk

Getting Started: http://developer.constantcontact.com/get-started.html

 

If you do need any additional information, please feel free to reply here and we will be happy to help!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Highlighted
Occasional Participant

Re: Arriving at the Constant Contact opt in registration via a PHP

Hi Elijah,

 

Thanks for the response & for helping me.

 

Sorry for the misunderstanding. I do NOT expect the PHP to fully subscribe a contact! I only want the PHP to arrive at the CC registration page (as the default form normally would when folks click "go").

 

So the good news is that I'm asking for something extremely simple: Is there PHP code that allows us to arrive at the CC registration? (I assume it is called the CC registration page, but in case it isnt, you can see the attachment, or glance at http://visitor.r20.constantcontact.com/manage/optin?v=001f3-uRxL1UByaf3hbjVyoXlqzixcbanb-02z5NBBFATZ... )

 

Sorry, the links you provided below are extremely confusing to me, and the PHP wrapper alone has 9 more links, multiple steps and installs... this is clearly not what I need & is overshooting our goal. We just want to arrive at the CC registration page from a PHP.

 

-Barry


screengrab_cc_registration.jpg
Highlighted
Honored Contributor

Re: Arriving at the Constant Contact opt in registration via a PHP

Hello Barry,

 

My apologies for misunderstanding what you were after!

 

It is possible to achieve what you are trying to do by redirecting from the PHP page once your other data has been processed. With the Constant Contact signup form, you can either POST the data through a form which redirects, or you can redirect and include all of the form fields and values directly on the URL.

 

For example, this would be the URL for the form in your original post: http://visitor.r20.constantcontact.com/d.jsp?llr=z4u4kndab&m={redacted}&p=oi&ea=test@test.com&go=Go

 

In this particular case, I am intentionally blanking the value for m, as that is a unique account ID. You can get that value by just going to the original form code and copying it.

 

If you are redirecting from a PHP page that has not sent any output, you can do a simple header redirect:

<?php

   header( 'Location: http://www.yoursite.com/new_page.html' ) ;

?>

 

However, if you are already outputitng information, you may need to use a javascript redirect or popup in order to direct the contact to the correct URL.

 

Let me know if you have additional questions!

 

Sincerely,

Elijah G.

API Support Specialist

 

 

Elijah G.
API Support Engineer
Highlighted
Occasional Participant

Re: Arriving at the Constant Contact opt in registration via a PHP

Wonderful, Elijah. Thanks!  We're making progress.

 

For the redirect header, we want to bring along their email address, so that it is not test@test.com

 

I tried adding $ea = $_POST['ea']; to the PHP. The header URL syntax assumes $ea is a string and not a variable. This is what I have currently, which results in an email address error when we arrive at the CC registration page:

 

<?php

$ea = $_POST['ea'];
header( 'Location: http://visitor.r20.constantcontact.com/d.jsp?llr=z4u4kndab&m={redacted}&p=oi&ea=$ea&go=Go' ) ;

?>

 

The theoretical user HAS entered their email address so we have that info when we arrive at the PHP. Is there an easy way to adjust the syntax above so that it adds their real email address into the header URL?

 

Thanks,

Barry

 

 

Highlighted
Moderator

Re: Arriving at the Constant Contact opt in registration via a PHP

With our JMML option and a header redirect, they will always be taken to a page that prompts for an email address.  If you wanted to automatically sync data behind the scenes without any additional user interaction, it would require API integration as mentioned by Elijah earlier in this thread.  Sorry about the limitation, will forward your feedback on to that development team. 

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Honored Contributor

Re: Arriving at the Constant Contact opt in registration via a PHP

Hi Barry,

 

Just a quick addition after reviewing this again. I noticed that the actual variable name $ea is being inserted into your string in PHP ratther than merging the value. This is because you're inserting $ea into a string encapsulated in single quotes vs double quotes. This is a feature of PHP to have a string type (single quote) that does not automatically merge variable names.

 

All you should need to do is change the header line to this:

header( "Location: http://visitor.r20.constantcontact.com/d.jsp?llr=z4u4kndab&m={redacted}&p=oi&ea=$ea&go=Go" ) ;

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Developer Portal

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

Visit Page

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