function AutoResponderGetResponseAPI($that, $ar, $wpm_id, $email, $unsub = false) { global $wpdb; require_once $that->pluginDir . '/extlib/jsonRPCClient.php'; if ($ar['campaign'][$wpm_id]) { $campaign = trim($ar['campaign'][$wpm_id]); $name = trim($that->ARSender['name']); $email = trim($that->ARSender['email']); $api_key = trim($ar['apikey']); $api_url = empty($ar['api_url']) ? "http://api2.getresponse.com" : trim($ar['api_url']); $grUnsub = $ar['grUnsub'][$wpm_id] == 1 ? true : false; $uid = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE `user_email`='" . esc_sql($that->ARSender['email']) . "'"); $ip = trim($that->Get_UserMeta($uid, 'wpm_login_ip')); $ip = $ip ? $ip : trim($that->Get_UserMeta($uid, 'wpm_registration_ip')); $ip = $ip ? $ip : trim($_SERVER['REMOTE_ADDR']); try { if (!extension_loaded('curl') || !extension_loaded('json')) { # these extensions are a must throw new Exception("CURL and JSON are modules required to use" . " the GetResponse Integration"); } $api = new jsonRPCClient($api_url); #get the campaign id $resp = $api->get_campaigns($api_key); $cid = null; if (!empty($resp)) { foreach ($resp as $i => $item) { if (strtolower($item['name']) == strtolower($campaign)) { $cid = $i; } } } if (empty($cid)) { throw new Exception("Could not find campaign {$campaign}"); } if ($unsub) { if ($grUnsub) { //list contacts $contacts = $api->get_contacts($api_key, array('campaigns' => array($cid), 'email' => array('EQUALS' => "{$email}"))); if (empty($contacts)) { #could not find the contact, nothing to remove return; } $pid = key($contacts); $res = $api->delete_contact($api_key, array('contact' => $pid)); if (empty($res)) { throw new Exception("Empty server response while deleting contact"); } } } else { $resp = $api->add_contact($api_key, array('campaign' => $cid, 'name' => $name, 'email' => $email, 'ip' => $ip, 'cycle_day' => 0)); if (empty($resp)) { throw new Exception("Empty server response while sending"); } } } catch (Exception $e) { return; } } }
public function indeed_getResponse($api_key, $token, $e_mail, $full_name = '') { require_once $this->dir_path . '/email_services/getresponse/jsonRPCClient.php'; $api = new jsonRPCClient('http://api2.getresponse.com'); $args = array('campaign' => $token, 'email' => $e_mail); if (!empty($full_name)) { $args['name'] = $full_name; } $res = $api->add_contact($api_key, $args); if ($res) { return 1; } else { return 0; } }
function process() { global $order; if (!$this->enabled) { return; } $client = new jsonRPCClient('http://api2.getresponse.com'); $result = NULL; try { $result = $client->get_campaigns(MODULE_ORDER_TOTAL_GETRESPONSE_API_KEY, array('name' => array('EQUALS' => MODULE_ORDER_TOTAL_GETRESPONSE_CAMPAIGN))); if (empty($result)) { throw new Exception('Missing GetResponse campaign: ' . MODULE_ORDER_TOTAL_GETRESPONSE_CAMPAIGN); } $client->add_contact(MODULE_ORDER_TOTAL_GETRESPONSE_API_KEY, array('campaign' => array_pop(array_keys($result)), 'name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'email' => $order->customer['email_address'], 'cycle_day' => '0', 'customs' => array(array('name' => 'ref', 'content' => STORE_NAME), array('name' => 'telephone', 'content' => $order->customer['telephone']), array('name' => 'country', 'content' => $order->customer['country']['title']), array('name' => 'city', 'content' => $order->customer['city'])))); } catch (Exception $e) { error_log($e->getMessage()); return; } }
/** * Subscribes to GetResponse list. Returns either "success" string or error message. * @return string */ function subscribe_get_response($list, $email, $api_key, $name = '-') { if (!function_exists('curl_init')) { return; } require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/getresponse/jsonrpcclient.php'; $api_url = 'http://api2.getresponse.com'; $name = '' == $name ? '-' : $name; $client = new jsonRPCClient($api_url); $result = $client->add_contact($api_key, array('campaign' => $list, 'name' => $name, 'email' => $email)); if (isset($result['result']['queued']) && 1 == $result['result']['queued']) { $result = 'success'; } else { if (isset($result['error']['message'])) { $result = $result['error']['message']; } else { $result = 'unknown error'; } } return $result; }
function snp_popup_submit() { global $wpdb; $result = array(); $errors = array(); $_POST['email'] = trim($_POST['email']); if (isset($_POST['name'])) { $_POST['name'] = trim($_POST['name']); } if (!snp_is_valid_email($_POST['email'])) { $errors['email'] = 1; } if (isset($_POST['name']) && !$_POST['name']) { $errors['name'] = 1; } $post_id = intval($_POST['popup_ID']); if ($post_id) { $POPUP_META = get_post_meta($post_id); } $cf_data = array(); if (isset($POPUP_META['snp_cf']) && $post_id) { $cf = unserialize($POPUP_META['snp_cf'][0]); if (isset($cf) && is_array($cf)) { foreach ($cf as $f) { if (isset($f['name'])) { if (strpos($f['name'], '[')) { $f['name'] = substr($f['name'], 0, strpos($f['name'], '[')); } if (!empty($_POST[$f['name']])) { $cf_data[$f['name']] = $_POST[$f['name']]; } } if (isset($f['required']) && $f['required'] == 'Yes' && !$cf_data[$f['name']]) { $errors[$f['name']] = 1; } } } } if (count($errors) > 0) { $result['Errors'] = $errors; $result['Ok'] = false; } else { $Done = 0; if (!empty($_POST['name'])) { $names = snp_detect_names($_POST['name']); } else { $names = array('first' => '', 'last' => ''); } $api_error_msg = ''; if (snp_get_option('ml_manager') == 'directmail') { require_once SNP_DIR_PATH . '/include/directmail/class.directmail.php'; $form_id = snp_get_option('ml_dm_form_id'); if ($form_id) { $api = new DMSubscribe(); $retval = $api->submitSubscribeForm($form_id, $_POST['email'], $error_message); if ($retval) { $Done = 1; } else { // Error... Send by email? $api_error_msg = $error_message; } } } elseif (snp_get_option('ml_manager') == 'sendy') { $list_id = $POPUP_META['snp_ml_sendy_list'][0]; if (!$list_id) { $list_id = snp_get_option('ml_sendy_list'); } if ($list_id) { $options = array('list' => $list_id, 'boolean' => 'true'); $args['email'] = $_POST['email']; if (!empty($_POST['name'])) { $args['name'] = $_POST['name']; } if (count($cf_data) > 0) { $args = array_merge($args, (array) $cf_data); } $content = array_merge($args, $options); $postdata = http_build_query($content); $ch = curl_init(snp_get_option('ml_sendy_url') . '/subscribe'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $api_result = curl_exec($ch); curl_close($ch); if (strval($api_result) == 'true' || strval($api_result) == '1' || strval($api_result) == 'Already subscribed.') { $Done = 1; } else { $api_error_msg = $api_result; } } } elseif (snp_get_option('ml_manager') == 'mailchimp') { require_once SNP_DIR_PATH . '/include/mailchimp/Mailchimp.php'; $ml_mc_list = $POPUP_META['snp_ml_mc_list'][0]; if (!$ml_mc_list) { $ml_mc_list = snp_get_option('ml_mc_list'); } if (snp_get_option('ml_mc_apikey') && $ml_mc_list) { $api = new Mailchimp(snp_get_option('ml_mc_apikey')); $args = array(); if (!empty($_POST['name'])) { $args = array('FNAME' => $names['first'], 'LNAME' => $names['last']); } if (count($cf_data) > 0) { $args = array_merge($args, (array) $cf_data); } try { $double_optin = snp_get_option('ml_mc_double_optin'); if ($double_optin == 1) { $double_optin = true; } else { $double_optin = false; } $double_optin = snp_get_option('ml_mc_double_optin'); if ($double_optin == 1) { $double_optin = true; } else { $double_optin = false; } $send_welcome = snp_get_option('ml_mc_send_welcome'); if ($send_welcome == 1) { $send_welcome = true; } else { $send_welcome = false; } $retval = $api->lists->subscribe($ml_mc_list, array('email' => $_POST['email']), $args, 'html', $double_optin, false, true, $send_welcome); $Done = 1; } catch (Exception $e) { if ($e->getCode() == 214) { $Done = 1; } else { $api_error_msg = $e->getMessage(); } } } } elseif (snp_get_option('ml_manager') == 'egoi') { $ml_egoi_apikey = snp_get_option('ml_egoi_apikey'); $client = new SoapClient('http://api.e-goi.com/v2/soap.php?wsdl'); try { $ml_egoi_list = $POPUP_META['snp_ml_egoi_list'][0]; if (!$ml_egoi_list) { $ml_egoi_list = snp_get_option('ml_egoi_list'); } $args = array('apikey' => $ml_egoi_apikey, 'listID' => $ml_egoi_list, 'email' => $_POST['email']); if (!empty($_POST['name'])) { $args['first_name'] = $names['first']; $args['last_name'] = $names['last']; } if (count($cf_data) > 0) { $CustomFields = array(); foreach ($cf_data as $k => $v) { $args[$k] = $v; } } $res = $client->addSubscriber($args); if (isset($res['UID'])) { $Done = 1; } } catch (Exception $e) { // Error... // We'll send this by email. } } elseif (snp_get_option('ml_manager') == 'getresponse') { $ml_gr_apikey = snp_get_option('ml_gr_apikey'); require_once SNP_DIR_PATH . '/include/getresponse/jsonRPCClient.php'; $api = new jsonRPCClient('http://api2.getresponse.com'); try { $ml_gr_list = $POPUP_META['snp_ml_gr_list'][0]; if (!$ml_gr_list) { $ml_gr_list = snp_get_option('ml_gr_list'); } $args = array('campaign' => $ml_gr_list, 'email' => $_POST['email']); if (!empty($_POST['name'])) { $args['name'] = $_POST['name']; } if (count($cf_data) > 0) { $CustomFields = array(); foreach ($cf_data as $k => $v) { $CustomFields[] = array('name' => $k, 'content' => $v); } $args['customs'] = $CustomFields; } $res = $api->add_contact($ml_gr_apikey, $args); $Done = 1; } catch (Exception $e) { // Error... // We'll send this by email. $api_error_msg = $e->getMessage(); } } elseif (snp_get_option('ml_manager') == 'campaignmonitor') { require_once SNP_DIR_PATH . '/include/campaignmonitor/csrest_subscribers.php'; $ml_cm_list = $POPUP_META['snp_ml_cm_list'][0]; if (!$ml_cm_list) { $ml_cm_list = snp_get_option('ml_cm_list'); } $wrap = new CS_REST_Subscribers($ml_cm_list, snp_get_option('ml_cm_apikey')); $args = array('EmailAddress' => $_POST['email'], 'Resubscribe' => true); if (!empty($_POST['name'])) { $args['Name'] = $_POST['name']; } if (count($cf_data) > 0) { $CustomFields = array(); foreach ($cf_data as $k => $v) { $CustomFields[] = array('Key' => $k, 'Value' => $v); } $args['CustomFields'] = $CustomFields; } $res = $wrap->add($args); if ($res->was_successful()) { $Done = 1; } else { // Error... // We'll send this by email. $api_error_msg = 'Failed with code ' . $res->http_status_code; } } elseif (snp_get_option('ml_manager') == 'icontact') { require_once SNP_DIR_PATH . '/include/icontact/iContactApi.php'; iContactApi::getInstance()->setConfig(array('appId' => snp_get_option('ml_ic_addid'), 'apiPassword' => snp_get_option('ml_ic_apppass'), 'apiUsername' => snp_get_option('ml_ic_username'))); $oiContact = iContactApi::getInstance(); $res1 = $oiContact->addContact($_POST['email'], null, null, isset($names['first']) ? $names['first'] : '', isset($names['last']) ? $names['last'] : '', null, null, null, null, null, null, null, null, null); if ($res1->contactId) { $ml_ic_list = $POPUP_META['snp_ml_ic_list'][0]; if (!$ml_ic_list) { $ml_ic_list = snp_get_option('ml_ic_list'); } if ($oiContact->subscribeContactToList($res1->contactId, $ml_ic_list, 'normal')) { $Done = 1; } } else { // Error... // We'll send this by email. $api_error_msg = 'iContact Problem!'; } } elseif (snp_get_option('ml_manager') == 'constantcontact') { require_once SNP_DIR_PATH . '/include/constantcontact/class.cc.php'; $cc = new cc(snp_get_option('ml_cc_username'), snp_get_option('ml_cc_pass')); $send_welcome = snp_get_option('ml_cc_send_welcome'); if ($send_welcome == 1) { $cc->set_action_type('contact'); } $email = $_POST['email']; $contact_list = $POPUP_META['snp_ml_cc_list'][0]; if (!$contact_list) { $contact_list = snp_get_option('ml_cc_list'); } $extra_fields = array(); if (!empty($names['first'])) { $extra_fields['FirstName'] = $names['first']; } if (!empty($names['last'])) { $extra_fields['LastName'] = $names['last']; } if (count($cf_data) > 0) { $extra_fields = array_merge($extra_fields, (array) $cf_data); } $contact = $cc->query_contacts($email); if ($contact) { $status = $cc->update_contact($contact['id'], $email, $contact_list, $extra_fields); if ($status) { $Done = 1; } else { $api_error_msg = "Contact Operation failed: " . $cc->http_get_response_code_error($cc->http_response_code); } } else { $new_id = $cc->create_contact($email, $contact_list, $extra_fields); if ($new_id) { $Done = 1; } else { $api_error_msg = "Contact Operation failed: " . $cc->http_get_response_code_error($cc->http_response_code); } } } elseif (snp_get_option('ml_manager') == 'madmimi') { require_once SNP_DIR_PATH . '/include/madmimi/MadMimi.class.php'; if (snp_get_option('ml_madm_username') && snp_get_option('ml_madm_apikey')) { $mailer = new MadMimi(snp_get_option('ml_madm_username'), snp_get_option('ml_madm_apikey')); $user = array('email' => $_POST['email']); if (!empty($names['first'])) { $user['FirstName'] = $names['first']; } if (!empty($names['last'])) { $user['LastName'] = $names['last']; } if (count($cf_data) > 0) { $user = array_merge($user, (array) $cf_data); } $ml_madm_list = $POPUP_META['snp_ml_madm_list'][0]; if (!$ml_madm_list) { $ml_madm_list = snp_get_option('ml_madm_list'); } $user['add_list'] = $ml_madm_list; $res = $mailer->AddUser($user); $Done = 1; } } elseif (snp_get_option('ml_manager') == 'infusionsoft') { require_once SNP_DIR_PATH . '/include/infusionsoft/infusionsoft.php'; if (snp_get_option('ml_inf_subdomain') && snp_get_option('ml_inf_apikey')) { $infusionsoft = new Infusionsoft(snp_get_option('ml_inf_subdomain'), snp_get_option('ml_inf_apikey')); $user = array('Email' => $_POST['email']); if (!empty($names['first'])) { $user['FirstName'] = $names['first']; } if (!empty($names['last'])) { $user['LastName'] = $names['last']; } if (count($cf_data) > 0) { $user = array_merge($user, (array) $cf_data); } $ml_inf_list = $POPUP_META['snp_ml_inf_list'][0]; if (!$ml_inf_list) { $ml_inf_list = snp_get_option('ml_inf_list'); } $contact_id = $infusionsoft->contact('add', $user); $r = $infusionsoft->APIEmail('optIn', $_POST['email'], "Ninja Popups on " . get_bloginfo()); if ($contact_id && $ml_inf_list) { $infusionsoft->contact('addToGroup', $contact_id, $ml_inf_list); } if ($contact_id) { $Done = 1; } } } elseif (snp_get_option('ml_manager') == 'aweber') { require_once SNP_DIR_PATH . '/include/aweber/aweber_api.php'; if (get_option('snp_ml_aw_auth_info')) { $aw = get_option('snp_ml_aw_auth_info'); try { $aweber = new AWeberAPI($aw['consumer_key'], $aw['consumer_secret']); $account = $aweber->getAccount($aw['access_key'], $aw['access_secret']); $aw_list = $POPUP_META['snp_ml_aw_lists'][0]; if (!$aw_list) { $aw_list = snp_get_option('ml_aw_lists'); } $list = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $aw_list); $subscriber = array('email' => $_POST['email'], 'ip' => $_SERVER['REMOTE_ADDR']); if (!empty($_POST['name'])) { $subscriber['name'] = $_POST['name']; } if (count($cf_data) > 0) { $subscriber['custom_fields'] = $cf_data; } $r = $list->subscribers->create($subscriber); $Done = 1; } catch (AWeberException $e) { $api_error_msg = $e->getMessage(); } } } elseif (snp_get_option('ml_manager') == 'wysija' && class_exists('WYSIJA')) { $ml_wy_list = $POPUP_META['snp_ml_wy_list'][0]; if (!$ml_wy_list) { $ml_wy_list = snp_get_option('ml_wy_list'); } $userData = array('email' => $_POST['email'], 'firstname' => $names['first'], 'lastname' => $names['last']); $data = array('user' => $userData, 'user_list' => array('list_ids' => array($ml_wy_list))); $userHelper =& WYSIJA::get('user', 'helper'); if ($userHelper->addSubscriber($data)) { $Done = 1; } else { $api_error_msg = 'MailPoet Problem!'; } } elseif (snp_get_option('ml_manager') == 'sendpress') { $ml_sp_list = $POPUP_META['snp_ml_sp_list'][0]; if (!$ml_sp_list) { $ml_sp_list = snp_get_option('ml_sp_list'); } try { SendPress_Data::subscribe_user($ml_sp_list, $_POST['email'], $names['first'], $names['last'], 2); $Done = 1; } catch (Exception $e) { $api_error_msg = 'SendPress Problem!'; } } elseif (snp_get_option('ml_manager') == 'mymail') { $userdata = array('firstname' => $names['first'], 'lastname' => $names['last']); $ml_mm_list = $POPUP_META['snp_ml_mm_list'][0]; if (!$ml_mm_list) { $ml_mm_list = snp_get_option('ml_mm_list'); } $lists = array($ml_mm_list); if (function_exists('mymail')) { $entry = $userdata; $entry['email'] = $_POST['email']; $double_optin = snp_get_option('ml_mm_double_optin'); if ($double_optin == 1) { $entry['status'] = 0; } else { $entry['status'] = 1; } if (count($cf_data) > 0) { foreach ($cf_data as $k => $v) { $entry[$k] = $v; } } $subscriber_id = mymail('subscribers')->add($entry, true); if (!is_wp_error($subscriber_id)) { $success = mymail('subscribers')->assign_lists($subscriber_id, $lists, false); } if ($success) { $Done = 1; } else { $api_error_msg = 'MyMail Problem!'; } } else { $return = mymail_subscribe($_POST['email'], $userdata, $lists); if (!is_wp_error($return)) { $Done = 1; } else { $api_error_msg = 'MyMail Problem!'; } } } elseif (snp_get_option('ml_manager') == 'csv' && snp_get_option('ml_csv_file') && is_writable(SNP_DIR_PATH . 'csv/')) { if (!isset($_POST['name'])) { $_POST['name'] = ''; } if (count($cf_data) > 0) { $CustomFields = ''; foreach ($cf_data as $k => $v) { $CustomFields .= $k . ' = ' . $v . ';'; } } $data = $_POST['email'] . ";" . $_POST['name'] . ";" . $CustomFields . get_the_title($_POST['popup_ID']) . " (" . $_POST['popup_ID'] . ");" . date('Y-m-d H:i') . ";" . $_SERVER['REMOTE_ADDR'] . ";\n"; if (file_put_contents(SNP_DIR_PATH . 'csv/' . snp_get_option('ml_csv_file'), $data, FILE_APPEND | LOCK_EX) !== FALSE) { $Done = 1; } else { $api_error_msg = 'CSV Problem!'; } } if (snp_get_option('ml_manager') == 'email' || !$Done) { $Email = snp_get_option('ml_email'); if (!$Email) { $Email = get_bloginfo('admin_email'); } if (!isset($_POST['name'])) { $_POST['name'] = '--'; } $error_mgs = ''; if ($api_error_msg != '') { $error_mgs .= "IMPORTANT! You have received this message because connection to your e-mail marketing software failed. Please check connection setting in the plugin configuration.\n"; $error_mgs .= $api_error_msg . "\n"; } $cf_msg = ''; if (count($cf_data) > 0) { foreach ($cf_data as $k => $v) { $cf_msg .= $k . ": " . $v . "\n"; } } $msg = "New subscription on " . get_bloginfo() . "\n" . $error_mgs . "\n" . "E-mail: " . $_POST['email'] . "\n" . "Name: " . $_POST['name'] . "\n" . $cf_msg . "\n" . "Form: " . get_the_title($_POST['popup_ID']) . " (" . $_POST['popup_ID'] . ")\n" . "\n" . "Date: " . date('Y-m-d H:i') . "\n" . "IP: " . $_SERVER['REMOTE_ADDR'] . ""; wp_mail($Email, "New subscription on " . get_bloginfo(), $msg); } $result['Ok'] = true; } echo json_encode($result); die(''); }
$api_key = 'ENTER_YOUR_API_KEY_HERE'; # API 2.x URL $api_url = 'http://api2.getresponse.com'; # initialize JSON-RPC client $client = new jsonRPCClient($api_url); $result = NULL; # get CAMPAIGN_ID of 'sample_marketing' campaign try { $result = $client->get_campaigns($api_key, array('name' => array('EQUALS' => 'sample_marketing'))); } catch (Exception $e) { # check for communication and response errors # implement handling if needed die($e->getMessage()); } # uncomment this line to preview data structure # print_r($result); # since there can be only one campaign of this name # first key is the CAMPAIGN_ID you need $campaigns = array_keys($result); $CAMPAIGN_ID = array_pop($campaigns); # add contact to 'sample_marketing' campaign try { $result = $client->add_contact($api_key, array('campaign' => $CAMPAIGN_ID, 'name' => 'Sample Name', 'email' => '*****@*****.**', 'cycle_day' => '0', 'customs' => array(array('name' => 'last_purchased_product', 'content' => 'netbook')))); } catch (Exception $e) { # check for communication and response errors # implement handling if needed die($e->getMessage()); } # uncomment this line to preview data structure # print_r($result); print "Contact added\n";
/** * Ajax newsletter * * @since 1.0.0 */ public function ajax_subscribe() { // No First Name if (!isset($_POST['first_name'])) { $_POST['first_name'] = ''; } // No Last Name if (!isset($_POST['last_name'])) { $_POST['last_name'] = ''; } $success_message = stripcslashes( $this->settings['subscribe']['success_message'] ); // MailChimp if ($_POST['type'] == 'mailchimp') { require_once('includes/mailchimp/MailChimp.php'); if (!isset($this->settings['subscribe']['mailchimp']['api_key']) || $this->settings['subscribe']['mailchimp']['api_key'] == '') { echo json_encode(array( 'status' => 'warning', 'message' => __('MailChimp account is not setup properly.'), )); die(); } if (!isset($this->settings['subscribe']['mailchimp']['list']) || $this->settings['subscribe']['mailchimp']['list'] == '') { echo json_encode(array( 'status' => 'warning', 'message' => __('MailChimp: No list specified.'), )); die(); } $MailChimp = new WPS_MailChimp($this->settings['subscribe']['mailchimp']['api_key']); $result = $MailChimp->call('lists/subscribe', array( 'id' => $this->settings['subscribe']['mailchimp']['list'], 'email' => array('email'=>sanitize_email( $_POST['email']) ), 'merge_vars' => array( 'FNAME'=> sanitize_text_field( $_POST['first_name'] ), 'LNAME'=>sanitize_text_field( $_POST['last_name'] ) ), 'double_optin' => true, 'update_existing' => false, 'replace_interests' => false, 'send_welcome' => true, )); if ($result) { if (isset($result['email'])) { echo json_encode(array( 'status' => 'check', 'message' => $success_message, )); die(); } else if (isset($result['status']) && $result['status'] == 'error') { echo json_encode(array( 'status' => 'warning', 'message' => $result['error'], )); die(); } } else { echo json_encode(array( 'status' => 'warning', 'message' => __('Unable to subscribe.'), )); die(); } } // Add email to aweber else if ($_POST['type'] == 'aweber') { require_once('includes/aweber/aweber_api.php'); if (!isset($this->settings['subscribe']['aweber']['consumer_key']) || $this->settings['subscribe']['aweber']['consumer_key'] == '') { echo json_encode(array( 'status' => 'warning', 'message' => __('Aweber account is not setup properly'), )); die(); } $aweber = new AWeberAPI($this->settings['subscribe']['aweber']['consumer_key'], $this->settings['subscribe']['aweber']['consumer_secret']); try { $account = $aweber->getAccount($this->settings['subscribe']['aweber']['access_key'], $this->settings['subscribe']['aweber']['access_secret']); $list = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $this->settings['subscribe']['aweber']['list']); $subscriber = array( 'email' => sanitize_email( $_POST['email'] ), 'name' => sanitize_text_field( $_POST['first_name'] ) . ' ' . sanitize_text_field( $_POST['last_name'] ), 'ip' => $_SERVER['REMOTE_ADDR'] ); $newSubscriber = $list->subscribers->create($subscriber); echo json_encode(array( 'status' => 'check', 'message' => $success_message, )); die(); } catch (AWeberAPIException $exc) { echo json_encode(array( 'status' => 'warning', 'message' => $exc->message, )); die(); } } // Add email to Get Response else if ($_POST['type'] == 'getresponse') { require_once('includes/getresponse/jsonRPCClient.php'); $api = new jsonRPCClient('http://api2.getresponse.com'); try { $api->add_contact( $this->settings['subscribe']['getresponse']['api_key'], array ( 'campaign' => $this->settings['subscribe']['getresponse']['campaign'], 'name' => sanitize_text_field( $_POST['first_name'] ) . ' ' . sanitize_text_field( $_POST['last_name'] ), 'email' => sanitize_email( $_POST['email'] ), ) ); echo json_encode(array( 'status' => 'check', 'message' => $success_message, )); die(); } catch (RuntimeException $exc) { $msg = $exc->getMessage(); $msg = substr($msg, 0, strpos($msg, ";")); echo json_encode(array( 'status' => 'warning', 'message' => $msg, )); die(); } } // Add email to Campaign Monitor else if ($_POST['type'] == 'campaignmonitor') { require_once('includes/campaignmonitor/csrest_subscribers.php'); $wrap = new CS_REST_Subscribers($this->settings['subscribe']['campaignmonitor']['list'], $this->settings['subscribe']['campaignmonitor']['api_key']); // Check if subscribor is already subscribed $result = $wrap->get(sanitize_email( $_POST['email'] )); if ($result->was_successful()) { echo json_encode(array( 'status' => 'warning', 'message' => 'You are already subscribed to this list.', )); die(); } $result = $wrap->add(array( 'EmailAddress' => sanitize_email($_POST['email']), 'Name' => sanitize_text_field( $_POST['first_name'] ). ' ' . sanitize_text_field( $_POST['last_name'] ), 'Resubscribe' => true )); if ($result->was_successful()) { echo json_encode(array( 'status' => 'check', 'message' => $success_message, )); die(); } else { echo json_encode(array( 'status' => 'warning', 'message' => $result->response->Message, )); die(); } } // Add email to Mad Mimi else if ($_POST['type'] == 'madmimi') { require_once('includes/madmimi/MadMimi.class.php'); $mailer = new MadMimi($this->settings['subscribe']['madmimi']['username'], $this->settings['subscribe']['madmimi']['api_key']); // No Email if (!isset($_POST['email']) || $_POST['email'] == '') { echo json_encode(array( 'status' => 'warning', 'message' => 'No Email address provided.' )); die(); } // Invalid Email Address if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { echo json_encode(array( 'status' => 'warning', 'message' => 'Invalid Email provided.' )); die(); } try { // Check if user is already in list $result = $mailer->Memberships(sanitize_email( $_POST['email']) ); $lists = new SimpleXMLElement($result); if ($lists->list) { foreach ($lists->list as $l) { if ($l->attributes()->{'name'}->{0} == $meta_values['madmimi_list']) { echo json_encode(array( 'status' => 'check', 'message' => 'You are already subscribed to this list.', )); die(); } } } $result = $mailer->AddMembership($this->settings['subscribe']['madmimi']['list'], sanitize_email( $_POST['email'] ), array( 'first_name' => sanitize_text_field( $_POST['first_name'] ), 'last_name' => sanitize_text_field( $_POST['last_name'] ), )); echo json_encode(array( 'status' => 'check', 'message' => $success_message, )); die(); } catch (RuntimeException $exc) { echo json_encode(array( 'status' => 'warning', 'message' => $msg, )); die(); } } die(); }
public function export() { $this->load->model('module/getresponse'); $contacts = $this->model_module_getresponse->getContacts(); $this->gr_apikey = $this->request->post['api_key']; $this->campaign = $this->request->post['campaign']; $this->load->library('jsonRPCClient'); try { $client = new jsonRPCClient($this->gr_apikey_url); $result = $client->get_campaigns($this->gr_apikey, array('name' => array('EQUALS' => $this->campaign))); } catch (Exception $e) { $this->data['error_warning'] = 'Error!' . $e; } if (empty($result)) { $results = array('status' => 2, 'response' => ' No campaign with the specified name.'); } else { $duplicated = 0; $queued = 0; $contact = 0; $not_added = 0; $allow_fields = array('telephone', 'country', 'city', 'address', 'postcode'); $campaign_id = key($result); foreach ($contacts as $row) { $customs = array(); $customs[] = array('name' => 'ref', 'content' => 'OpenCart'); foreach ($allow_fields as $af) { if (!empty($row[$af])) { $customs[] = array('name' => $af, 'content' => $row[$af]); } } $check_cycle_day = $client->get_contacts($this->gr_apikey, array('campaigns' => array($campaign_id), 'email' => array('EQUALS' => $row['email']))); if (!empty($check_cycle_day) and is_array($check_cycle_day)) { $res = array_shift($check_cycle_day); $cycle_day = $res['cycle_day']; } else { $cycle_day = '0'; } $params = array('campaign' => $campaign_id, 'name' => $row['firstname'] . ' ' . $row['lastname'], 'email' => $row['email'], 'cycle_day' => $cycle_day, 'customs' => $customs); try { $r = $client->add_contact($this->gr_apikey, $params); $contact++; if (array_key_exists('queued', $r)) { $queued++; } else { if (array_key_exists('duplicated', $r)) { $duplicated++; } } } catch (Exception $e) { $not_added++; } } $results = array('status' => 1, 'response' => ' Export completed. Contacts: ' . $contact . '. Queued:' . $queued . '. Updated: ' . $duplicated . '. Not added (Contact already queued): ' . $not_added . '.'); } $this->response->setOutput(json_encode($results)); }
public function affwp_add_to_getresponse($name, $email, $user_id) { if (empty($name) || empty($email) || empty($user_id)) { return; } $getresponse_campaign_id = affiliate_wp()->settings->get('affwp_getresponse_campaign_id'); $getresponse_api_key = affiliate_wp()->settings->get('affwp_getresponse_api_key'); $getresponse_api_key = trim($getresponse_api_key); if (!class_exists('jsonRPCClient')) { require_once 'classes/jsonRPCClient.php'; } $api_url = 'http://api2.getresponse.com'; $client = new jsonRPCClient($api_url); try { $response = $client->add_contact($getresponse_api_key, array('campaign' => $getresponse_campaign_id, 'name' => $name, 'email' => $email, 'ip' => $_SERVER['REMOTE_ADDR'], 'cycle_day' => 0)); update_user_meta($user_id, 'tbz_affwp_subscribed_to_getresponse', 'yes'); return true; } catch (Exception $e) { return false; } }
/** * Record an impression made by a optin fire * This function is called via PHP. * * @access public * @static * @return void */ function nnr_new_int_add_email_v1() { do_action('nnr_news_int_before_submission_add_email_v1'); // No First Name if (!isset($_POST['first_name'])) { $_POST['first_name'] = ''; } // No Last Name if (!isset($_POST['last_name'])) { $_POST['last_name'] = ''; } // Could not find Data ID if (!isset($_POST['data_id']) || $_POST['data_id'] == '') { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('Could not find Data ID.', $_POST['text_domain']))); die; } // Get all newsletter data for this data instance $data_manager = new NNR_Data_Manager_v1($_POST['table_name']); $data_instance = $data_manager->get_data_from_id($_POST['data_id']); $success_action = isset($data_instance['args']['newsletter']['success_action']) ? stripcslashes($data_instance['args']['newsletter']['success_action']) : 'message'; $success_mesage = isset($data_instance['args']['newsletter']['success_message']) ? stripcslashes($data_instance['args']['newsletter']['success_message']) : __('Welcome to the community!', $_POST['text_domain']); $success_url = isset($data_instance['args']['newsletter']['success_url']) ? stripcslashes($data_instance['args']['newsletter']['success_url']) : ''; // No Email if (!isset($_POST['email']) || $_POST['email'] == '') { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('No Email address provided.', $_POST['text_domain']))); die; } // Invalid Email Address if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('Invalid Email provided.', $_POST['text_domain']))); die; } // WordPress if ($_POST['type'] == 'wordpress') { $newsletter_db = new NNR_Newsletter_Integrations_Submission_v1($_POST['news_table_name']); $result = $newsletter_db->add_data(array('data_id' => $_POST['data_id'], 'email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'])); if ($result) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } else { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'message' => __('We already have your email!', $_POST['text_domain']))); die; } } else { if ($_POST['type'] == 'mailchimp') { require_once dirname(dirname(__FILE__)) . '/services/mailchimp/MailChimp.php'; if (!isset($data_instance['args']['newsletter']['mailchimp']['api_key']) || $data_instance['args']['newsletter']['mailchimp']['api_key'] == '') { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('MailChimp account is not setup properly.', $_POST['text_domain']))); die; } if (!isset($data_instance['args']['newsletter']['mailchimp']['list']) || $data_instance['args']['newsletter']['mailchimp']['list'] == '') { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('MailChimp: No list specified.', $_POST['text_domain']))); die; } if (!isset($data_instance['args']['newsletter']['mailchimp']['optin'])) { $data_instance['args']['newsletter']['mailchimp']['optin'] = true; } $MailChimp = new NNR_New_Int_MailChimp($data_instance['args']['newsletter']['mailchimp']['api_key']); $result = $MailChimp->call('lists/subscribe', array('id' => $data_instance['args']['newsletter']['mailchimp']['list'], 'email' => array('email' => $_POST['email']), 'merge_vars' => array('FNAME' => $_POST['first_name'], 'LNAME' => $_POST['last_name']), 'double_optin' => $data_instance['args']['newsletter']['mailchimp']['optin'], 'update_existing' => false, 'replace_interests' => false, 'send_welcome' => true)); if ($result) { if (isset($result['email'])) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } else { if (isset($result['status']) && $result['status'] == 'error') { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $result['error'])); die; } } } else { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('Unable to subscribe.', $_POST['text_domain']))); die; } } else { if ($_POST['type'] == 'aweber') { require_once dirname(dirname(__FILE__)) . '/services/aweber/aweber_api.php'; $aweber = new AWeberAPI($data_instance['args']['newsletter']['aweber']['consumer_key'], $data_instance['args']['newsletter']['aweber']['consumer_secret']); try { $account = $aweber->getAccount($data_instance['args']['newsletter']['aweber']['access_key'], $data_instance['args']['newsletter']['aweber']['access_secret']); $list = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $data_instance['args']['newsletter']['aweber']['list_id']); $subscriber = array('email' => $_POST['email'], 'name' => $_POST['first_name'] . ' ' . $_POST['last_name'], 'ip' => $_SERVER['REMOTE_ADDR']); $newSubscriber = $list->subscribers->create($subscriber); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } catch (AWeberAPIException $exc) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $exc->message)); die; } } else { if ($_POST['type'] == 'getresponse') { require_once dirname(dirname(__FILE__)) . '/services/getresponse/jsonRPCClient.php'; $api = new jsonRPCClient('http://api2.getresponse.com'); try { $api->add_contact($data_instance['args']['newsletter']['getresponse']['api_key'], array('campaign' => $data_instance['args']['newsletter']['getresponse']['campaign'], 'name' => $_POST['first_name'] . ' ' . $_POST['last_name'], 'email' => $_POST['email'])); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } catch (RuntimeException $exc) { $msg = $exc->getMessage(); $msg = substr($msg, 0, strpos($msg, ";")); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $msg)); die; } } else { if ($_POST['type'] == 'campaignmonitor') { require_once dirname(dirname(__FILE__)) . '/services/campaignmonitor/csrest_subscribers.php'; $wrap = new CS_REST_Subscribers($data_instance['args']['newsletter']['campaignmonitor']['list'], $data_instance['args']['newsletter']['campaignmonitor']['api_key']); // Check if subscriber is already subscribed $result = $wrap->get($_POST['email']); if ($result->was_successful()) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('You are already subscribed to this list.', $_POST['text_domain']))); die; } $result = $wrap->add(array('EmailAddress' => $_POST['email'], 'Name' => $_POST['first_name'] . ' ' . $_POST['last_name'], 'Resubscribe' => true)); if ($result->was_successful()) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } else { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $result->response->Message)); die; } } else { if ($_POST['type'] == 'madmimi') { require_once dirname(dirname(__FILE__)) . '/services/madmimi/MadMimi.class.php'; $mailer = new MadMimi($data_instance['args']['newsletter']['madmimi']['username'], $data_instance['args']['newsletter']['madmimi']['api_key']); try { // Check if user is already in list $result = $mailer->Memberships($_POST['email']); $lists = new SimpleXMLElement($result); if ($lists->list) { foreach ($lists->list as $l) { if ($l->attributes()->{'name'}->{0} == $data_instance['args']['newsletter']['madmimi']['list']) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'message' => __('You are already subscribed to this list.', $_POST['text_domain']))); die; } } } $result = $mailer->AddMembership($data_instance['args']['newsletter']['madmimi']['list'], $_POST['email'], array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'])); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } catch (RuntimeException $exc) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $msg)); die; } } else { if ($_POST['type'] == 'infusionsoft') { require_once dirname(dirname(__FILE__)) . '/services/infusionsoft/isdk.php'; try { $infusion_app = new iSDK(); $infusion_app->cfgCon($data_instance['args']['newsletter']['infusionsoft']['app_id'], $data_instance['args']['newsletter']['infusionsoft']['api_key'], 'throw'); } catch (iSDKException $e) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $e->getMessage())); die; } if (empty($error_message)) { $contact_data = $infusion_app->dsQuery('Contact', 1, 0, array('Email' => $_POST['email']), array('Id', 'Groups')); // Check if contact already exists if (0 < count($contact_data)) { if (false === strpos($contact_data[0]['Groups'], $data_instance['args']['newsletter']['infusionsoft']['list'])) { $infusion_app->grpAssign($contact_data[0]['Id'], $data_instance['args']['newsletter']['infusionsoft']['list']); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } else { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'message' => __('You are already subscribed to this list.', $_POST['text_domain']))); die; } } else { $new_contact_id = $infusion_app->dsAdd('Contact', array('FirstName' => $_POST['first_name'], 'LastName' => $_POST['last_name'], 'Email' => $_POST['email'])); $infusion_app->grpAssign($new_contact_id, $data_instance['args']['newsletter']['infusionsoft']['list']); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } } } else { if ($_POST['type'] == 'mymail') { // Check if plugin is activated if (!function_exists('mymail')) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('MyMail is not activated.', $_POST['text_domain']))); die; } // Add subscriber $subscriber_id = mymail('subscribers')->add(array('email' => $_POST['email'], 'firstname' => $_POST['first_name'], 'lastname' => $_POST['last_name']), false); // Add to List if (!is_wp_error($subscriber_id)) { mymail('subscribers')->assign_lists($subscriber_id, array($data_instance['args']['newsletter']['mymail']['list'])); echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } else { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'message' => __('You are already subscribed to this list.', $_POST['text_domain']))); die; } } else { if ($_POST['type'] == 'activecampaign') { require_once dirname(dirname(__FILE__)) . '/services/activecampaign/ActiveCampaign.class.php'; $ac = new ActiveCampaign($data_instance['args']['newsletter']['activecampaign']['app_url'], $data_instance['args']['newsletter']['activecampaign']['api_key']); if (!(int) $ac->credentials_test()) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('Unable to to connect to Active Campaign.', $_POST['text_domain']))); die; } // Add subscriber $contact_sync = $ac->api("contact/add", array("email" => $_POST['email'], "first_name" => $_POST['first_name'], "last_name" => $_POST['last_name'], "p[" . $data_instance['args']['newsletter']['activecampaign']['list'] . "]" => $data_instance['args']['newsletter']['activecampaign']['list'], "status[" . $data_instance['args']['newsletter']['activecampaign']['list'] . "]" => 1)); if ((int) $contact_sync->success) { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'check', 'success_action' => $success_action, 'url' => $success_url, 'message' => $success_mesage, 'conversion' => apply_filters('nnr_news_int_submission_success_v1', array('data_id' => $_POST['data_id'], 'table_name' => $_POST['stats_table_name'])))); die; } else { echo json_encode(array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => $contact_sync->error)); die; } } } } } } } } } } do_action('nnr_news_int_after_submission_add_email_v1'); echo json_encode(apply_filters('nnr_news_int_submission_add_email_v1', array('id' => $_POST['data_id'], 'status' => 'warning', 'message' => __('Unable to subscribe user. Newsletter not setup properly.', $_POST['text_domain'])))); die; // this is required to terminate immediately and return a proper response }
function add_new_contact(){ $name = $_POST['name']; $email = $_POST['email']; $mailer_id = $_POST['mailer_id']; $campaign_id = $_POST['campaign_id']; $tracker_id = $_POST['tracker_id']; switch($mailer_id){ // GetResponse case 1: $getresponse_api_key = get_option('wpcb_getresponse_api_key'); include_once(plugin_dir_path(dirname(__FILE__)).'admin/mailers/getresponse-api.php'); $getresponse = new jsonRPCClient('http://api2.getresponse.com'); try{ $result_contact = $getresponse->add_contact($getresponse_api_key, array ('campaign' => $campaign_id,'name' => $name,'email' => $email,'cycle_day' => 0)); global $wpdb; $wpcb_tbl_name = $this->get_tracking_table_name(); $wpdb->update($wpcb_tbl_name, array('visittype' => 'optin'), array('id' => $tracker_id), array('%s'), array('%d')); echo 1; } catch (Exception $e){ echo $e; } break; // MailChimp case 2: $mailchimp_api_key = get_option('wpcb_mailchimp_api_key'); include_once(plugin_dir_path(dirname(__FILE__)).'admin/mailers/mailchimp-api.php'); $mailchimp = new MCAPI($mailchimp_api_key); $merge_vars = array('FNAME' => $name, 'LNAME' => ''); $retval = $mailchimp->listSubscribe($campaign_id, $email, $merge_vars, 'html', true, true); if($mailchimp->errorCode){ echo 0; } else { global $wpdb; $wpcb_tbl_name = $this->get_tracking_table_name(); $wpdb->update($wpcb_tbl_name, array('visittype' => 'optin'), array('id' => $tracker_id), array('%s'), array('%d')); echo 1; } break; // Aweber case 3: include_once(plugin_dir_path(dirname(__FILE__)).'admin/mailers/aweber_api/aweber_api.php'); try { $aweber_api_key = get_option('wpcb_aweber_api_key'); $aweber_data = unserialize($aweber_api_key); $aweber = new AWeberAPI($aweber_data[0], $aweber_data[1]); $account = $aweber->getAccount($aweber_data[2], $aweber_data[3]); $account_id = $account->id; $listURL = "/accounts/".$account_id."/lists/".$campaign_id; $list = $account->loadFromUrl($listURL); $params = array( 'email' => $email, 'name' => $name ); $subscribers = $list->subscribers; $new_subscriber = $subscribers->create($params); global $wpdb; $wpcb_tbl_name = $this->get_tracking_table_name(); $wpdb->update($wpcb_tbl_name, array('visittype' => 'optin'), array('id' => $tracker_id), array('%s'), array('%d')); echo 1; } catch (Exception $exc) { echo 0; } break; // MailPoet case 9 :$mailpoet_data = array( 'user' => array('email' => $email, 'firstname' => $name), 'user_list' => array('list_ids' => array($campaign_id)) ); // Add subscriber to MailPoet. $userHelper = WYSIJA::get('user', 'helper'); $userHelper->addSubscriber($mailpoet_data); global $wpdb; $wpcb_tbl_name = $this->get_tracking_table_name(); $wpdb->update($wpcb_tbl_name, array('visittype' => 'optin'), array('id' => $tracker_id), array('%s'), array('%d')); $this->data['success'] = true; echo 1; die(); break; // Feedburner case 11:$feedburner_uri = get_option('wpcb_feedburner_uri'); global $wpdb; $wpcb_tbl_name = $this->get_tracking_table_name(); $wpdb->update($wpcb_tbl_name, array('visittype' => 'optin'), array('id' => $tracker_id), array('%s'), array('%d')); echo 1; break; } die(); }