Submitting subscription forms transparantly to Interspire Email Marketer
Published 05/27/2008 by Hendri Kurniawan
Quite a few users have asked about methods to subscribe a user transparently from their website (ie. When they purchased a product from your website, and have opt-in to subscribe to your mailing list), and don't want to get the "Thank you" page displayed after the subscription process. Or when you want to simplify your subscription process by just asking only to fill their email address, and you pre-fill the form for them (ie. Set the format to HTML, etc).
There are two ways to achieve this:
On this occasion, I will talk about how to use a wrapper to achieve this. This is because it is fast, and does not require any knowledge of the Interspire Email Marketer inner workings, and in addition, it will shield your code from any changes that are made in the subscription process.
A quick illustration on how this will work is as follow:
First of all, you need to create a subscription web-form.... Please de-select the option to use CAPTCHA (As we want to keep the subscription form as simple as possible). After the creation is complete, you need to take note of the form ID.
Now the next process is to create your subscription form:
There are two ways to achieve this:
- Using the API -- Which means:
- You need to understand how the API works
- When the subscription process change, your code will also be obsolete (and you need to re-write them)
- Using a wrapper that act as an intermediate between your subscription HTML form and the Interspire Email Marketer
On this occasion, I will talk about how to use a wrapper to achieve this. This is because it is fast, and does not require any knowledge of the Interspire Email Marketer inner workings, and in addition, it will shield your code from any changes that are made in the subscription process.
A quick illustration on how this will work is as follow:
+----------------+ +-------------------+ +-----------------------------+ | Your HTML Page | ==> | Your PHP page | ==> | Interspire Email Marketter | | | <== | | <== | | +----------------+ +-------------------+ +-----------------------------+
First of all, you need to create a subscription web-form.... Please de-select the option to use CAPTCHA (As we want to keep the subscription form as simple as possible). After the creation is complete, you need to take note of the form ID.
Now the next process is to create your subscription form:
<html>
<form action="forms_wrapper.php" method="POST">
Please enter your email address:
<input type="text" name="txtEmail" />
<input type="button" name="cmdSubscribe" value="Subscribe" />
</form>
</html>
And create a PHP wrapper file that will send the request to Interspire Email Marketer:
<?php
$data = array(
'format' => 'h',
'email' => $_POST['txtEmail']
);
$ch = curl_init(CONST_YOUR_IEM_URL . '/form.php?form=' . CONST_YOUR_FORMID);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = @curl_exec($ch);
curl_close($ch);
// Response will contains Interspire Email Marketer response to your subscription.
// It will either be success (Thank you page)
// Or it will contains the error page
?>A working example can be downloaded here
If you have any queries about this I will be glad to answer them. Simply leave me a comment bellow.
2 Responses to "Submitting subscription forms transparantly to Interspire Email Marketer" 
|
said this on 09 Jul 2008 1:59:19 AM CST
Hi and thanks for this article. I have done something like this in the past with SS NX. I have a couple of quick questions:
1. RE Line 8: - curl_setopt($ch, CURLOPT_POST, 0); Why is the CURLOPT_POST set to 0 and not 1 ? I was informed by Hendri on a previous occassion that I should use 1 for POST to POST the data to EM. 2. I am not clear on what $response does. Can you elaborate on that for me please ? |
|
said this on 09 Jul 2008 6:30:26 PM CST
Hi John,
1. The CURLOPT_POST option works either way (using 1 or 0), but you are right, I need to put curl_setopt($ch, CURLOPT_POST, 1); instead. I will rectify my example 2. $response holds the html string that your installation will sent back. If you print the variable out, you will get a full HTML page. So based on that, you can check whether or not your submission was successful. |

Author/Admin)