I've searched the threads in the forums and could not find what I thought would be a common question.
The sample code (php) creates a multi step process for a visitor to be added to a list. i.e. the edit_contact_step1.php has the visitor enter their email address, then the code will open a new form for the visitor to complete(either add_contact or edit_contact) depending on whether the email address exists in the CC customer contacts (regardless of list association) even though no additional information is actually required.
This process is requiring a visitor to take excessive action (IMHO) to complete the sign-up (remember, if they are new, they will again be required to confirm their intentions once again via an email if COI is enabled). Whew... I'm frustrated even describing it!
Anyhow, I've tried to dissect the code of each page to create a single step submission process that will take the initial visitor form data (name and email), validate it against the CC customer contacts, and immediately add or edit the contact data as appropriate without further visitor interaction.
I've got the forced list issue covered so an existing contact would simply need their record updated to include the new list and a new contact doesn't need to concern themselves with which list they need to sign up for.
This process seems straight forward to me but I'm having fits trying to reverse engineer the sample code.
Has anyone accompished this sort of API before and if so, could I have peek at the code?
Our Sample code tries to give an example of everything that our API's can do, so it can be complex when you are just trying to use the API to add a contact in a simple form. Usually if you are just trying to do a very simple sign up form, we would recommend using our Custom Signup Form which you can get here. This allows you to create a simple sign up form with PHP, without having to program it yourself. This will not, however, check to see if the contact is already in the system, and will just tell people who already signed up that they have already done so.
If you do need further customization, in order to add a contact using our API's by hand, you need to use our Contact Collection API using the correct XML which you can find in the link that I just gave. First you would want to do a search using our search function found here. If the contact exists you would do a PUT call to the Contact Collection URI, if it does not exist you would do the post.
If you have any further questions, please feel free to let me know by posting here on the forums!