The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Just Making Sure I understand the Changes

Highlighted
Occasional Participant

Just Making Sure I understand the Changes

I have read the updates and everything it seems pretty straight forward but I wanted to make sure that my changes were going to be ok before I unleased them since I have a very limited way of checking if it works.. aka, new member signs up and finds out it didn't work.


curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); <---- I changed this line below to this, is this all I have to do? Or am I missing anything else? The directions are vague at best but it's just that easy then well good job.


 


Thanks!


$entry = '<entry xmlns="http://www.w3.org/2005/Atom">

                        <title type="text"> </title>

                        <updated>' . date('c') . '</updated>

                        <author></author>

                        <id>data:,none</id>

                        <summary type="text">Contact</summary>

                        <content type="application/vnd.ctct+xml">

                        <Contact xmlns="http://ws.constantcontact.com/ns/1.0/">

                        <EmailAddress>' . $email . '</EmailAddress>

                        <EmailType>' . $newsletter_type . '</EmailType>

                        <FirstName>' . $first_name . '</FirstName>

                        <LastName>' . $last_name . '</LastName>

                        <City>' . $city . '</City>

                        <StateCode>' . $StateCode . '</StateCode>

                        <OptInSource>ACTION_BY_CONTACT</OptInSource>

                        <ContactLists>

                        <ContactList id="http://api.constantcontact.com/ws/customers/' . $UN . '/lists/6" />

                        </ContactLists>

                        </Contact>

                        </content>

                        </entry>';

                       

                        // Initialize the cURL session

                        $request ="http://api.constantcontact.com/ws/customers/" . $UN . "/contacts";

                        $session = curl_init($request);

                       

                        // Set up digest authentication

                        $userNamePassword = $Key . '%' . $UN . ':' . $PW ;

                       

                        // Set cURL options

                        curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

                        curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);

                        curl_setopt($session, CURLOPT_POST, 1);

                        curl_setopt($session, CURLOPT_POSTFIELDS , $entry);

                        curl_setopt($session, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));

                        curl_setopt($session, CURLOPT_HEADER, false); // Do not return headers

                        curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); // If you set this to 0, it will take you to a page with the http response

                       

                        // Execute cURL session and close it

                        $response = curl_exec($session);

                        curl_close($session);

3 REPLIES 3
Highlighted
Moderator

It looks like you haven't

It looks like you haven't changed your request URI to be https still.  Please see our Basic Authentication guide for how to correctly convert your code to support Basic Authentication over HTTPS.


 


http://developer.constantcontact.com/doc/authenticationBasic

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Participant

I'm ganna go out on a limb

I'm ganna go out on a limb here and I'm ganna guess that since I read that documentation AND posted a forum post that I'm not going to get anymore help or a simple yes, but you need to change the address "$request ="http://api.constantcontact.com/ws/customers/" . $UN . "/contacts";" to $request ="https://api.constantcontact.com/ws/customers/" . $UN . "/contacts";? Am I CORRECT? 


I have to comment that the support I have received when asking a pretty simple question has been subpar on this support forum. I understand that in doing code that most people understand EVERYTHING but sometimes there are people that don't understand the basic simple things when they are SO far advanced as this switch has been made to be.  I asked a simple question a couple months ago about getting information from the database and displaying it to the customer so they can edit but I never got a response that was worth anything to continue coding that section of the website.


I am very pleased with the ability to send a sweet looking newsletter but signing people up for it, WAY HARDER then it should be.


Thanks for the help. If the above changes are all I need to make then I hope that's it. If not PLEASE be more specific because I have read that documentation that you sent me to and it has NOTHING to do with what I was doing with my code and if it did then I'm missing something BIG TIME!


Thanks!

Highlighted
Moderator

I'm sorry for the slightly

I'm sorry for the slightly vague answer.  Typically the process is as simple as you're stating.  You have to change the Authentication type to basic as you already did and change the request URI to https instead of http.  The reason that it is not a simple cut and dry answer on that though is there are some servers and hosting services that may require additional configuration changes.


 


A high percentage of our customers are able to simply execute the two changes are mentioned and are pointed out in the documentation I linked you.  We try to qualify the answer though to make sure you understand that in some environments there are configuration changes which may need to be made and those are beyond the support we are able to give for our developers.


 


Regarding your older question, I'm not familiar with your previous request, but if you're having some confusion using the API to retrieve information we are more than happy to help clear up those issues.  I will see if I can find your previous post and look at the problems you were having.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured