Created
October 5, 2012 18:54
-
-
Save jonesch/3841680 to your computer and use it in GitHub Desktop.
Submitting to Exact Target with cURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //I am using this for an AJAX call, and checking my responses against the success or failure that it is echoing back. | |
//create array of data to be posted | |
$full_name = stripslashes(trim(strip_tags($_POST['full_name']))); | |
$email_address = stripslashes(trim(strip_tags($_POST['email_address']))); | |
if(!empty($full_name) && !empty($email_address)){ | |
$post_data['MID'] = "10488043"; | |
$post_data['Full Name'] = $full_name; | |
$post_data['Email Address'] = $email_address; | |
$post_data['thx'] = ''; | |
$post_data['err'] = ''; | |
//create the final string to be posted using implode() | |
$post_str = implode ('&', $post_data); | |
foreach($data as $key=>$val) { | |
$post_string .= $key.'='.urlencode($val).'&'; | |
} | |
$post_str = substr($post_str, 0, -1); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'http://cl.exct.net/subscribe.aspx?lid=18086381'); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
echo 'success'; | |
} else { | |
echo 'failure'; | |
} | |
?> |
Hello Cincy,
Sorry for the late reply, but you can def. do that within the same AJAX call. After you echo 'success', you can build a form using PHP's mail function. You should be able to get started using php.net/mail as a reference.
I hope that works out for yah!
Hello jones,
i want to submit an html form but the form does not do the submission by itself ,in the action part of the form i have a php file that is collecting the data and then would now submit into an api(8 fields) i have so that i receive a response and further have a redirect link to the page i should go to once the data submission is successful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jones,
I am in the process of building a PHP cURL for submissions to Exact Target.
My client would like the form info submitted and also emailed to them.
Wondering if I can do the same with your AJAX call?