} else { echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later.")); errorlog("icontact", "Lists data not found."); } } catch (Exception $oException) { // Catch any exceptions echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later.")); $oiErrors = $oiContact->getErrors(); foreach ($oiErrors as $key => $value) { errorlog("icontact", $value); } } } elseif ($STORE_MODE == "constantcontact") { $list_name = $CC_LIST_NAME; $list_id = null; $cc = new Ctct\ConstantContact($CC_API_KEY); try { try { $lists = $cc->getLists($CC_ACCESS_TOKEN); if (is_array($lists) && sizeof($lists) > 0) { foreach ($lists as $key => $value) { if (isset($value->name) && $value->name == $list_name) { $list_id = $value->id; } } } if (isset($email) && strlen($email) > 1 && $list_id != null) { $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($CC_ACCESS_TOKEN, $email);
<?php if (!isset($contactform_obj) || isset($contactform_obj) && !is_object($contactform_obj) || !isset($_POST['form_values']) || !isset($json_error_array) || $json_error_array || !isset($element_ids_values) || !$element_ids_values) { exit; } if (!empty($cfg['constantcontact']['apikey']) && !empty($cfg['constantcontact']['accesstoken']) && !empty($cfg['constantcontact']['lists'])) { $service_id = 'constantcontact'; include '../api/Ctct/autoload.php'; $cc = new Ctct\ConstantContact($cfg[$service_id]['apikey']); foreach ($cfg[$service_id]['lists'] as $list_v) { $list_id = $list_v['list_id']; $merge_vars = array(); $api_contact_email = ''; $api_action = ''; // EMAIL FIELD FOR getContactByEmail() if (!empty($list_v['fields'])) { foreach ($list_v['fields'] as $fields_v) { if ($fields_v['list_field_id'] == 'email') { $api_contact_email = $element_ids_values[$fields_v['element_id']]['element_value'][0]; break; } } } if ($api_contact_email) { try { $response = $cc->getContactByEmail($cfg[$service_id]['accesstoken'], $api_contact_email); // ADD if (empty($response->results)) { $cc_contact = new Ctct\Components\Contacts\Contact(); $cc_contact->addEmail($api_contact_email); /*