| Server IP : 67.43.7.42 / Your IP : 216.73.216.61 Web Server : Apache System : Linux host.isabellascookies.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : isabella ( 503) PHP Version : 5.5.38 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/isabella/public_html/constant/update/ |
Upload File : |
<?php
//print_r($_POST);
$postFields = array();
$postFields["success_url"] = $_REQUEST["SuccessURL"];
$postFields["failure_url"] = $_REQUEST["FailureURL"];
$errors=array();
// require the autoloader
require_once '../src/Ctct/autoload.php';
use Ctct\ConstantContact;
use Ctct\Components\Contacts\Contact;
use Ctct\Components\Contacts\ContactList;
use Ctct\Components\Contacts\EmailAddress;
use Ctct\Exceptions\CtctException;
// Enter your Constant Contact APIKEY and ACCESS_TOKEN
define("APIKEY", "kt7dypwdm7ryka4ymc4cqm99");
define("ACCESS_TOKEN", "9986ff84-c420-4b38-8f35-103b21196351");
$cc = new ConstantContact(APIKEY);
// attempt to fetch lists in the account, catching any exceptions and printing the errors to screen
try {
$lists = $cc->getLists(ACCESS_TOKEN);
} catch (CtctException $ex) {
foreach ($ex->getErrors() as $error) {
print_r($error);
}
}
// check if the form was submitted
if (isset($_POST['email']) && strlen($_POST['email']) > 1) {
$action = "Getting Contact By Email Address";
try {
// check to see if a contact with the email addess already exists in the account
//$response = $cc->getContactByEmail(ACCESS_TOKEN, $_POST['email']);
// create a new contact if one does not exist
//if (empty($response->results)) {
$action = "Creating Contact";
$contact = new Contact();
$contact->addEmail($_POST['email']);
$contact->addList($_POST['list']);
$contact->first_name = $_POST['first_name'];
$contact->last_name = $_POST['last_name'];
/*
* The third parameter of addContact defaults to false, but if this were set to true it would tell Constant
* Contact that this action is being performed by the contact themselves, and gives the ability to
* opt contacts back in and trigger Welcome/Change-of-interest emails.
*
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
*/
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact, true);
// update the existing contact if address already existed
/*} else {
$action = "Updating Contact";
$contact = $response->results[0];
$contact->addList($_POST['list']);
$contact->first_name = $_POST['first_name'];
$contact->last_name = $_POST['last_name'];*/
/*
* The third parameter of updateContact defaults to false, but if this were set to true it would tell
* Constant Contact that this action is being performed by the contact themselves, and gives the ability to
* opt contacts back in and trigger Welcome/Change-of-interest emails.
*
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
*/
/* $returnContact = $cc->updateContact(ACCESS_TOKEN, $contact, false);
}*/
// catch any exceptions thrown during the process and print the errors to screen
} catch (CtctException $ex) {
/*echo '<span class="label label-important">Error ' . $action . '</span>';
echo '<div class="container alert-error"><pre class="failure-pre">';
*/
$errors=$ex->getErrors();
//print_r($errors);
/*echo '</pre></div>';
die();*/
}
if(isset($errors) && isset($errors[0]))
{
echo 0;
if($postFields["failure_url"]){
//header('Location:'.$postFields["failure_url"]);
}
else {
// echo '<div id="code" title="409"></div><h3>We\'re Sorry!</h3><p>It appears that you are already a subscriber of our mailing list.</p>';
}
}
else
{
echo 1;
if($postFields["success_url"]){
//header('Location:'.$postFields["success_url"]);
}
else {
//echo '<div id="code" title="201"></div><h3>Thank you!</h3><p>Your interest preferences have been successfully recorded.</p>';
}
}
}
?>