/** * Get List from Sendy */ function cspv4_get_sendy_lists($apikey = null) { global $seed_cspv4; extract($seed_cspv4); $o = $seed_cspv4; $lists = array(); if ($o['emaillist'] == 'sendy' || defined('DOING_AJAX') && DOING_AJAX && isset($_GET['action']) && $_GET['action'] == 'seed_cspv4_refresh_list') { $lists = unserialize(get_transient('seed_cspv4_sendy_lists')); if ($lists === false) { //var_dump('SENDY MISS'); require_once SEED_CSPV4_PLUGIN_PATH . 'extentions/sendy/seed_cspv4_MCAPI.class.php'; if (!isset($apikey) && isset($sendy_api_key)) { $apikey = $sendy_api_key; } if (empty($apikey)) { return array(); } $api = new seed_cspv4_MCAPI($apikey); $response = $api->lists(); if ($response['total'] === 0) { $lists['false'] = __("No lists Found", 'seedprod'); return $lists; } if ($api->errorCode) { $lists['false'] = __("Unable to load Sendy lists, check your API Key.", 'seedprod'); } else { foreach ($response['data'] as $k => $v) { $lists[$v['id']] = $v['name']; } if (!empty($lists)) { set_transient('seed_cspv4_sendy_lists', serialize($lists), 86400); } } } } return $lists; }
function seed_cspv4_emaillist_mailchimp_add_subscriber($args) { global $seed_cspv4, $seed_cspv4_post_result; extract($seed_cspv4); require_once SEED_CSPV4_PLUGIN_PATH . 'extentions/mailchimp/seed_cspv4_MCAPI.class.php'; require_once SEED_CSPV4_PLUGIN_PATH . 'lib/nameparse.php'; // If tracking enabled if (!empty($enable_reflink)) { seed_cspv4_emaillist_database_add_subscriber(); } $apikey = $mailchimp_api_key; $api = new seed_cspv4_MCAPI($apikey); $listId = $mailchimp_listid; if (!empty($mailchimp_enable_double_optin)) { $double_optin = true; } else { $double_optin = false; } if (!empty($mailchimp_welcome_email)) { $welcome_email = true; } else { $welcome_email = false; } if (!empty($mailchimp_replace_interests)) { $replace_interests = true; } else { $replace_interests = false; } if (!empty($mailchimp_update_existing)) { $update_existing = true; } else { $update_existing = false; } $name = ''; if (!empty($_REQUEST['name'])) { $name = $_REQUEST['name']; } $email = $_REQUEST['email']; $fname = ''; $lname = ''; if (!empty($name)) { $name = seed_cspv4_parse_name($name); $fname = $name['first']; $lname = $name['last']; } $merge_vars = array('FNAME' => $fname, 'LNAME' => $lname, 'REFID' => $seed_cspv4_post_result['ref'], 'REFURL' => $seed_cspv4_post_result['ref_url']); if (!empty($mailchimp_groups) && !empty($mailchimp_group_name)) { $merge_vars['GROUPINGS'] = array(array('name' => $mailchimp_group_name, 'groups' => $mailchimp_groups)); } $retval = $api->listSubscribe($listId, $email, apply_filters('seed_cspv4_mailchimp_merge_vars', $merge_vars), $email_type = 'html', $double_optin, $update_existing, $replace_interests, $welcome_email); if ($retval == false) { if ($api->errorCode == 214 && !empty($enable_reflink)) { } elseif (!empty($api->errorMessage)) { $seed_cspv4_post_result['msg'] = $api->errorMessage; $seed_cspv4_post_result['msg_class'] = 'alert-info'; } } else { if ($seed_cspv4_post_result['status'] == '600') { $seed_cspv4_post_result['status'] = '200'; } if (empty($seed_cspv4_post_result['status'])) { $seed_cspv4_post_result['status'] = '200'; } } }