inline integration

Highlighted
Occasional Participant

inline integration

I am new to constanct contact.  A client of mine has registered and will be using this service for their email management.  I do have a lot of php/html experience.  I have downloaded the samples and have read through some threads.  I do not think this will be hard to do but need a little direction.


What we are trying to do:


We currently have a event registration process that customers use to let us know they will be attending seminars.  We are trying to tie in an inline integration into the newsletter lists inside of constant contact.  This is all php html code.  The addition of a contact would include email, name and address info and should not impede or change the result of the php code.  Meaning we need to be able to submit the contact via the api and then ignore any response and continue.  So if it is a duplicate, then dont add it but do not break.  If there are any errors at all essentially we still need to be able to keep going to complete the event registration as that is the number 1 priority.  We also need to programmatically determine the list to subscribe to.  For example if the client says they are of type A, then we put them in in list A, type B - list B etc.


Questions:


1) It appears that this is doable by just calling the add contact request inside of our php processing.  Am I just dreaming here?


2) How do we programmatically select the list.  The listing array does not seem that it would be friendly with this approach.  It seems that you either let the user pick the list or turn them off.  The user will actually have no interact with the listing form or anything else, this will all be behind the scense


3) Can you add a user to all lists that are set up?


 


Thanks in advance


 


Greg

15 REPLIES 15
Highlighted
Occasional Participant

much to my surprise I was

much to my surprise I was able to integrate the call to the constant contact api pretty easily.  It is adding the contacts to a certain list which I have hardcoded


    $postFields = array('https://api.constantcontact.com/ws/customers/{username}/lists/3');


I am thinking for this that I just need to set the postfield list value to the appropriate list id based on the select list in the form.  With that said, is there a way to add the subscriber to all lists?


Also the subscribe works but then I get a header back.  So the contact is created on the specified list and then it dumps out with this




Warning: Cannot modify header information - headers already sent by


The normal rest of the cannot modify header info displays with my script.  Anyone have any idea on how I can stop this?

Highlighted
Occasional Participant

ok I got the character fixed

ok I got the character fixed by adding the header and utf content type to the top


 


however I am still getting the header issue.  Is there any way to get around this?


 


Greg

Highlighted
CTCT Employee

Hi Greg, Regarding your

Hi Greg,


 


Regarding your header issue, this is often caused by outputting a character to the screen before that header. This is usually solved by checking the follow 2 things:


1) Find the header() statement that is causing the problem. The error must be at or before this line.


 


2) Make sure there is no white space outside of the php start and end tags.


 


With that being said, judging by the issue you were discussing earlier with the  symbol, it looks like you may have a Byte Order Mark saved with your file. This can happen if our original file contained that, or if the application you used to save the .php file placed a byte order mark in your file.


 


Also, to answer your questions:

1) If you already have processing that is going on, and you're just looking to also add your contact to a list during this process, this can be done by Creating a Contact and catching any errors that were thrown so that it will not break your flow.


 


2) Your process of hard coding the list would be the best way to modify the already existing sample forms to have the functionality you're looking for, so the process your using seems fine to me.


 


3) There is no way to add a contact to all lists at this time. You could certainly Get a Listing of Contact Lists , loop through the return to get the ID of each list, and then Add the Contact to multiple lists creating a separate <ContactList> element for each of your list Id's.

David J

Highlighted
Occasional Participant

Thanks for the reply

Thanks for the reply David


I have moved the code in the flow so that it is not after the post and before the header redirect.  This is not ideal as I have to put the code in 2 different places.  I use dreamweaver and have been coding for years.  Not that I am a pro or anything but I have chased that header many times and have already checked the things you have mentioned.  This is however my first run with a BOM.  Is there a way to check for it in dreamweaver or do I need Notepad++ etc?


Sounds good on #2


The client actually answered #3.  They are able to do this by the way they set up the lists.  THey can set up sub groups and if you are in a sub group you get the parent group communications etc.  In affect signing them up the  parent list or all lists etc.


 


So the only real remaining issue is that header violation and the BOM although I do have a work around for it.  The work around leads me to believe that it is something in the constant contact code.  If I take the call out, everything works fine.  I did edit the class file in notepad to put in our credentials.  maybe that did it?


Thanks


Greg

Highlighted
CTCT Employee

Re: Thanks for the reply

If your website is hosted online, I typically use the w3.org Byte Order mark quick check to test for a BOM. You can find this (as well as more info) on the right side of the following page http://www.w3.org/International/questions/qa-byte-order-mark.


 


Although I have not had any reports of a BOM in one of our files, if there one it is certainly something I'd like to remove. If you could either reply to this post with the file you're experienceing this issue in as well as your cc_class.php, or email them to our webservices support team I'd be happy to take a look. I do know however that Notepad does insert a BOM into UTF-8 files by default, so you may want to look at saving that with a different application and see if that resolves your issue as well.

David J

Highlighted
Occasional Participant

I saved a new version of the

I saved a new version of the cc_class with dreamweaver instead of notepad and the crazy chars are gone.


 


I am still however getting the header issue.  Something in there somewhere in the cc_class is writing a header or writing something else causing this hang up.  My only solution at this point is to restructure the logic so that the list addition is done after the post/headers when the page reloads.  Not ideal, but it is working for now.

Highlighted
CTCT Employee

Re: I saved a new version of the

There is a function in the CC_Utility class called doServerCall() that will attempt to echo out curl errors if there is one, and if curl_debug is set to true on line 29 of cc_class.php.


 


I would try setting line 29 to:


 


  var $curl_debug = false;


 


and see if this resolves your header issue. 


 


Again if you want to send me the files your using I can take a look to see if I can pinpoint this, but without that I'm just taking an educated guess.

David J

Highlighted
Occasional Participant

unfortunately i am on a

unfortunately i am on a TIGHT deadline to finish this code asap so I have just stuck with the duplicated code.  I can email you my files but I have to keep moving forward.  I have a version with the bad headers.  However without my dev env, I am not sure how much you will be able to check.


Will that email adress you listed above go straight to you?


Also the debug is set to false.  I have even tried commenting out any responses from the class etc.


 


Thanks




Greg

Highlighted
CTCT Employee

Re: unfortunately i am on a

Emailing that address will go into a queue for our web services team, but I'm watching that and will make sure I pick your ticket up.

David J

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