本文整理汇总了PHP中MailChimp类的典型用法代码示例。如果您正苦于以下问题:PHP MailChimp类的具体用法?PHP MailChimp怎么用?PHP MailChimp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MailChimp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: populate
/**
* get campaign data from the API and store it in our table
*/
public function populate($api_key, $list_id, $echo_feedback = false)
{
$MailChimp = new MailChimp($api_key);
if ($echo_feedback) {
$API = new PerchAPI(1.0, 'perch_mailchimp');
$Lang = $API->get('Lang');
}
$opts = array('apikey' => $api_key, 'filters' => array('list_id' => $list_id, 'status' => 'sent'));
$result = $MailChimp->call('campaigns/list', $opts);
if ($result && isset($result['total']) && $result['total'] > 0) {
foreach ($result['data'] as $item) {
$campaignID = $item['id'];
//get the content
$content_opts = array('apikey' => $api_key, 'cid' => $campaignID);
$content = $MailChimp->call('campaigns/content', $content_opts);
if (isset($content['html'])) {
$campaignHTML = $content['html'];
}
if (isset($content['text'])) {
$campaignText = $content['text'];
}
// array for insertion
$campaign = array('campaignCID' => $campaignID, 'campaignWebID' => $item['web_id'], 'campaignTitle' => $item['title'], 'campaignCreateTime' => $item['create_time'], 'campaignSendTime' => $item['send_time'], 'campaignSent' => $item['emails_sent'], 'campaignSubject' => $item['subject'], 'campaignArchiveURL' => $item['archive_url'], 'campaignHTML' => $campaignHTML, 'campaignText' => $campaignText, 'campaignSlug' => PerchUtil::urlify(date('d M Y', strtotime($item['create_time'])) . ' ' . $item['subject']));
//insert into our table
$this->db->insert($this->table, $campaign);
if ($echo_feedback) {
echo '<li class="icon success">';
echo $Lang->get('Importing campaign %s (%s)', $item['title'], $item['create_time']);
echo '</li>';
flush();
}
}
}
}
开发者ID:connor-baer,项目名称:waterford-website,代码行数:37,代码来源:PerchMailchimp_Campaigns.class.php
示例2: mwpc_ajax_result
function mwpc_ajax_result()
{
// check nonce
$nonce = $_POST['nextNonce'];
if (!wp_verify_nonce($nonce, 'mapajax-next-nonce')) {
die('Sorry, Server is busy. Try again after few minutes!');
}
if ($_POST['url'] == '' and $_POST['email'] != '') {
require_once 'MailChimp.php';
$MailChimp = new MailChimp('6c58e9c609ac5cbb9d71f9358a1a834a-us8');
$result = $MailChimp->call('lists/subscribe', array('id' => 'b90220a492', 'email' => array('email' => $_POST['email']), 'merge_vars' => array('FNAME' => $_POST['name']), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
if ($result === FALSE) {
echo 'no';
} else {
echo 'yes';
}
update_option('dv_subscribed', 'yes');
} else {
$url = $_POST['url'];
$zip_file = str_replace(site_url(), ABSPATH, $url);
$zip = new ZipArchive();
if ($zip->open($zip_file) === TRUE) {
$zip->extractTo(PLUGIN_BASE . DIRECTORY_SEPARATOR . 'templates');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
}
die;
}
开发者ID:nitishmittal1990,项目名称:coupon,代码行数:31,代码来源:template_installer.php
示例3: subscribeCount
public function subscribeCount()
{
$MailChimp = new MailChimp($this->api_key);
$params = ['fields' => 'stats.member_count'];
$result = $MailChimp->get('lists/' . $this->list_key, ['fields' => 'id,name,stats.member_count']);
return JsonResponse::create($result);
}
开发者ID:bakgat,项目名称:klimtoren-portal,代码行数:7,代码来源:MailChimpController.php
示例4: Walter
Part of the code from the book
Building Findable Websites: Web Standards, SEO, and Beyond
by Aarron Walter ([email protected])
http://buildingfindablewebsites.com
Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/
function storeAddress()
{
// Validation
if (empty($_REQUEST['email'])) {
return "No email address provided";
}
if (!preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\$/i", $_REQUEST['email'])) {
return "Email address is invalid";
}
// grab an API Key from http://admin.mailchimp.com/account/api/
$api_key = 'your-api-code-here';
// grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
// Click the "settings" link for the list - the Unique Id is at the bottom of that page.
$list_id = "your-list-id-here";
require_once 'MailChimp.php';
$dopt = !empty($_REQUEST['dopt']) && $_REQUEST['dopt'] == 'true' ? true : false;
$email = $_REQUEST['email'];
$merge_vars = array('FNAME' => !empty($_REQUEST['fname']) ? $_REQUEST['fname'] : '', 'LNAME' => !empty($_REQUEST['lname']) ? $_REQUEST['lname'] : '');
$api = new MailChimp($api_key);
$valid_key = $api->validateApiKey();
if (!$valid_key) {
return 'Error: please, check your api-key';
}
$result = $api->call('lists/subscribe', array('id' => $list_id, 'email' => array('email' => $email), 'merge_vars' => $merge_vars, 'double_optin' => $dopt, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
if (!empty($result['email']) && !empty($result['euid']) && !empty($result['leid'])) {
return 'Success! Check your email to confirm sign up.';
} else {
开发者ID:codeHatcher,项目名称:dewDropWebsite,代码行数:34,代码来源:store-address.php
示例5: smamo_ajax_newsletter
function smamo_ajax_newsletter()
{
$response = array();
$email = wp_strip_all_tags($_POST['email']);
$api_key = wp_strip_all_tags($_POST['api_key']);
$list_ID = wp_strip_all_tags($_POST['list_ID']);
if (!$email || $email === '') {
$response['error'] = 'Indtast venligst en email';
echo json_encode($response);
wp_die();
}
if (!$api_key || $api_key === '') {
$response['error'] = 'Mangler API nøgle';
echo json_encode($response);
wp_die();
}
if (!$list_ID || $list_ID === '') {
$response['error'] = 'Mangler liste ID';
echo json_encode($response);
wp_die();
}
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->call('lists/subscribe', array('id' => $list_ID, 'email' => array('email' => $email), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
$response['mailchimp'] = $result;
$response['destroy_self'] = '5000';
$response['success'] = '<span class="subscribe-success">Thank you</span>';
echo json_encode($response);
wp_die();
}
开发者ID:JeppeSigaard,项目名称:4smaritime,代码行数:29,代码来源:newsletter.php
示例6: check_list_for_interest_groups
public static function check_list_for_interest_groups($list_id = '', $integration_type = '', $load = false)
{
if (!$list_id) {
$list_id = $_POST['list_id'];
}
if (!$integration_type) {
$integration_type = $_POST['integration'];
}
$api_key = get_option('yikes-mc-api-key', '');
// setup/check our transients
if (WP_DEBUG || false === ($interest_groupings = get_transient($list_id . '_interest_group'))) {
// It wasn't there, so regenerate the data and save the transient
try {
// initialize MailChimp Class
$MailChimp = new MailChimp($api_key);
// retreive our interest group data
$interest_groupings = $MailChimp->call('lists/interest-groupings', array('apikey' => $api_key, 'id' => $list_id, 'counts' => false));
} catch (Exception $error) {
$interest_groupings = $error->getMessage();
}
// set the transient for 2 hours
set_transient($list_id . '_interest_group', $interest_groupings, 2 * HOUR_IN_SECONDS);
}
if (isset($interest_groupings) && !empty($interest_groupings)) {
require YIKES_MC_PATH . 'admin/partials/menu/options-sections/templates/integration-interest-groups.php';
}
// do not kill off execution on load, only on an ajax request
if (!$load) {
exit;
wp_die();
}
}
开发者ID:annbransom,项目名称:techishowl-wp,代码行数:32,代码来源:class.ajax.php
示例7: subscriber_add
/**
* Add new subscriber
*/
public function subscriber_add()
{
// simple api class for MailChimp from https://github.com/drewm/mailchimp-api/blob/master/src/Drewm/MailChimp.php
require_once Utils::api_path() . 'mailchimp-api.php';
foreach ($this->instance_default as $key => $value) {
${$key} = !empty($instance[$key]) ? $instance[$key] : $value;
}
$return = array('status' => 'failed', 'message' => $failed_message);
$email = sanitize_email($_POST['email']);
$api_key = $_POST['api-key'];
$list_id = $_POST['list-id'];
// Create MailChimp API object
$mailerAPI_obj = new MailChimp($api_key);
if (is_email($email) && !empty($api_key) && $mailerAPI_obj->validate_api_key()) {
// Call API
$result = $mailerAPI_obj->call('/lists/subscribe', array('id' => $list_id, 'email' => array('email' => $email, 'euid' => time() . rand(1, 1000), 'leid' => time() . rand(1, 1000)), 'double_optin' => true), 20);
if (!empty($result['leid'])) {
// Success response
$return = array('status' => 'success', 'message' => $success_message);
} else {
$return['message'] = $failed_message;
}
$return['result'] = $result;
}
// Send answer
wp_send_json($return);
}
开发者ID:gcofficial,项目名称:basetheme,代码行数:30,代码来源:monster-subscribe-and-social-widget.php
示例8: mc_nl_mail
function mc_nl_mail()
{
if (isset($_POST['nl_mail'])) {
$email_address = $_POST['nl_mail'];
include_once "lib/MailChimp.php";
$mc_api = get_option('sssoon_mailing_options');
$mc_api_key = $mc_api['mailchimp_api'];
$mc_list = $mc_api['mclist'];
$MailChimp = new MailChimp($mc_api_key);
$MailChimp->post('lists/' . $mc_list . '/members', array('email_address' => $email_address, 'status' => 'subscribed'));
}
}
开发者ID:timcreative,项目名称:coming-sssoon-wordpress-plugin,代码行数:12,代码来源:sssoon.php
示例9: executeSubscribe
public function executeSubscribe(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$email = $request->getParameter('email');
$validator = new sfValidatorEmail();
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
try {
$validator->clean($email);
$MailChimp = new MailChimp(sfConfig::get('app_mailchimp_api_key'));
$result = $MailChimp->call('lists/subscribe', array('id' => sfConfig::get('app_mailchimp_list_id'), 'email' => array('email' => $email), 'merge_vars' => array(), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
return $this->renderText(json_encode(array('status' => 'ok')));
} catch (sfValidatorError $e) {
return $this->renderText(json_encode(array('status' => 'invalid')));
}
}
开发者ID:sensorsix,项目名称:app,代码行数:15,代码来源:actions.class.php
示例10: indeed_mailChimp
public function indeed_mailChimp($mailchimp_api, $mailchimp_id_list, $e_mail, $first_name = '', $last_name = '')
{
if ($mailchimp_api != '' && $mailchimp_id_list != '') {
if (!class_exists('MailChimp')) {
require_once $this->dir_path . '/email_services/mailchimp/MailChimp.php';
}
$MailChimp = new MailChimp($mailchimp_api);
$result = $MailChimp->call('lists/subscribe', array('id' => $mailchimp_id_list, 'email' => array('email' => $e_mail), 'double_optin' => 0, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => 0, 'merge_vars' => array('FNAME' => $first_name, 'LNAME' => $last_name)));
if (!empty($result['email']) && !empty($result['euid']) && !empty($result['leid'])) {
return 1;
} else {
return 0;
}
}
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:15,代码来源:IhcMailServices.class.php
示例11: populate
/**
*
*/
public function populate($api_key, $list_id, $echo_feedback = false)
{
$MailChimp = new MailChimp($api_key);
if ($echo_feedback) {
$API = new PerchAPI(1.0, 'perch_mailchimp');
$Lang = $API->get('Lang');
}
$opts = array('apikey' => $api_key, 'filters' => array('list_id' => $list_id));
$result = $MailChimp->call('lists/list', $opts);
if ($result) {
$this->db->execute('TRUNCATE TABLE ' . $this->table);
//store title in data array
$stats_array = array('title' => $result['data'][0]['name'], 'total' => $result['data'][0]['stats']['member_count']);
$list_opts = array('apikey' => $api_key, 'id' => $list_id);
$activity = $MailChimp->call('lists/activity', $list_opts);
PerchUtil::debug($activity);
foreach ($activity as $stat) {
if ($stat['day'] == date('Y-m-d', strtotime('-1 days'))) {
$stats_array['yesterday'] = $stat['subs'] + $stat['other_adds'];
} elseif ($stat['day'] == date('Y-m-d')) {
$stats_array['today'] = $stat['subs'] + $stat['other_adds'];
}
}
//insert stats array
$this->db->insert($this->table, $stats_array);
if ($echo_feedback) {
echo '<li class="icon success">';
echo $Lang->get('Importing statistics for list %s', $list_id);
echo '</li>';
flush();
}
// history table
$sql = 'SELECT * FROM ' . PERCH_DB_PREFIX . 'mailchimp_history WHERE historyDate = ' . $this->db->pdb(date('Y-m-d', strtotime('-1 days'))) . ' LIMIT 1';
if (!($row = $this->db->get_row($sql))) {
//insert a row for yesterday
$history_data = array('historyDate' => date('Y-m-d', strtotime('-1 days')), 'historyTotal' => $stats_array['yesterday']);
$this->db->insert(PERCH_DB_PREFIX . 'mailchimp_history', $history_data);
if ($echo_feedback) {
echo '<li class="icon success">';
echo $Lang->get('Importing history for list %s', $list_id);
echo '</li>';
flush();
}
}
}
return true;
}
开发者ID:connor-baer,项目名称:waterford-website,代码行数:50,代码来源:PerchMailchimp_Stats.class.php
示例12: subscribe_from_form
public function subscribe_from_form($Form)
{
$Settings = $this->api->get('Settings');
$api_key = $Settings->get('perch_mailchimp_api_key')->settingValue();
$list_id = $Settings->get('perch_mailchimp_list_id')->settingValue();
$merge_vars = array();
$groupings = array();
$confirmed = false;
$double_optin = true;
$send_welcome = true;
$update_existing = true;
$replace_interests = false;
$FormTag = $Form->get_form_attributes();
if ($FormTag->is_set('double_optin')) {
$double_optin = $FormTag->double_optin();
}
if ($FormTag->is_set('send_welcome')) {
$send_welcome = $FormTag->send_welcome();
}
$attr_map = $Form->get_attribute_map('mailer');
if (PerchUtil::count($attr_map)) {
foreach ($attr_map as $fieldID => $merge_var) {
switch ($merge_var) {
case 'email':
$email = $Form->data[$fieldID];
break;
case 'confirm_subscribe':
$confirmed = PerchUtil::bool_val($Form->data[$fieldID]);
break;
default:
$merge_vars[$merge_var] = $Form->data[$fieldID];
break;
}
}
}
if ($confirmed) {
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->call('lists/subscribe', array('id' => $list_id, 'email' => array('email' => $email), 'merge_vars' => $merge_vars, 'double_optin' => $double_optin, 'update_existing' => $update_existing, 'replace_interests' => $replace_interests, 'send_welcome' => $send_welcome));
return $result;
}
return false;
}
开发者ID:connor-baer,项目名称:waterford-website,代码行数:42,代码来源:PerchMailchimp_Subscribers.class.php
示例13: smamo_puzzle_form
function smamo_puzzle_form()
{
$response = array();
$post_vars = array('state' => isset($_POST['state']) && $_POST['state'] !== '' ? true : false, 'solve-time' => isset($_POST['solve-time']) ? wp_strip_all_tags($_POST['solve-time']) : false, 'name' => isset($_POST['name']) ? wp_strip_all_tags($_POST['name']) : false, 'email' => isset($_POST['email']) ? wp_strip_all_tags($_POST['email']) : false);
// state og solve-time skal være sat til true
if (!$post_vars['state'] || !$post_vars['solve-time']) {
$response['error'] = 'cheats!';
wp_die(json_encode($response));
}
// Navn skal udfyldes
if (!$post_vars['name']) {
$response['error'] = 'Indtast et navn';
wp_die(json_encode($response));
}
// Email skal udfyldes
if (!$post_vars['email']) {
$response['error'] = 'Indtast en email';
wp_die(json_encode($response));
}
if (!$post_vars['state'] === '3') {
$response['error'] = 'you shouldnt be here, son';
wp_die(json_encode($response));
}
// Opret slack notifikation
if (function_exists('slack')) {
$text = $post_vars['name'] . ' har lige tilmeld sig nyhedsbrevet!';
$attachments = array(array('pretext' => '', 'color' => '#669999', 'fields' => array(array('title' => 'Navn', 'value' => $post_vars['name'], 'short' => false), array('title' => 'Email', 'value' => '<mailto:' . $post_vars['email'] . '|' . $post_vars['email'] . '>', 'short' => false), array('title' => 'Tid på puslespil', 'value' => $post_vars['solve-time'], 'short' => false))));
$response['slack_curl'] = slack($text, $attachments);
}
// Opret subscriber
if (class_exists('MailChimp')) {
$api_key = '40bbbefd42e7b7fd5e22c5e0e9ca61b3-us10';
$list_ID = '51f08ecfa7';
$response['mc-creds'] = array('key' => $api_key, 'list' => $list_ID);
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->call('lists/subscribe', array('id' => $list_ID, 'email' => array('email' => $post_vars['email']), 'merge_vars' => array('NAME' => $post_vars['name']), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
$response['mailchimp'] = $result;
}
wp_die(json_encode($response));
}
开发者ID:JeppeSigaard,项目名称:smamo16,代码行数:40,代码来源:puzzle-form.php
示例14: actionSynchronize
public function actionSynchronize()
{
set_time_limit(7200);
$idNameGroup = array();
$criteria = new CDbCriteria();
$mSubG = SubscriberGroup::model()->findAll($criteria);
if (count($mSubG) > 0) {
foreach ($mSubG as $i) {
$idNameGroup[$i->id] = $i->name;
}
}
$criteria = new CDbCriteria();
$criteria->addCondition('subscriber_group_id = 1 OR subscriber_group_id = 2');
$mSubscriber = Subscriber::model()->findAll($criteria);
//var_dump($mSubscriber);
$test = array();
if (count($mSubscriber) > 0) {
Yii::import('ext.MailChimp.MailChimp', true);
foreach ($mSubscriber as $item) {
$mailChimp = new MailChimp();
// $mailChimp->removeSubscriber('[email protected]');
// die;
$sGroupName = Yii::app()->params['mailchimp_title_groups'];
$sGroup = strtolower($idNameGroup[$item->subscriber_group_id]);
$merge_vars = array('GROUPINGS' => array(array('name' => $sGroupName, 'groups' => $sGroup)));
if ($item->status == 1) {
// echo '<pre>';
//echo print_r($merge_vars);
//echo '</pre>';
//echo $item->email;
//die();
$test[] = $mailChimp->addSubscriber($item->email, $merge_vars);
} else {
$mailChimp->removeSubscriber($item->email);
}
}
}
Yii::app()->user->setFlash('mailchimp', "Synchronize Mailling list successfully!");
$this->redirect(Yii::app()->createAbsoluteUrl("admin/setting/mailchimp"));
}
开发者ID:jasonhai,项目名称:onehome,代码行数:40,代码来源:MailchimpController.php
示例15: _drawSettingForm
/**
* Display form allows users to change settings on subscription plan add/edit screen
* @param object $row
*/
function _drawSettingForm($row)
{
require_once dirname(__FILE__) . '/api/MailChimp.php';
$mailchimp = new MailChimp($this->params->get('api_key'));
$lists = $mailchimp->call('lists/list');
if ($lists === false) {
} else {
$params = new JRegistry($row->params);
$listIds = explode(',', $params->get('mailchimp_list_ids', ''));
$options = array();
$lists = $lists['data'];
if (count($lists)) {
foreach ($lists as $list) {
$options[] = JHtml::_('select.option', $list['id'], $list['name']);
}
}
?>
<table class="admintable adminform" style="width: 90%;">
<tr>
<td width="220" class="key">
<?php
echo JText::_('PLG_OSMEMBERSHIP_MAILCHIMP_ASSIGN_TO_LISTS');
?>
</td>
<td>
<?php
echo JHtml::_('select.genericlist', $options, 'mailchimp_list_ids[]', 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $listIds);
?>
</td>
<td>
<?php
echo JText::_('PLG_OSMEMBERSHIP_ACYMAILING_ASSIGN_TO_LISTS_EXPLAIN');
?>
</td>
</tr>
</table>
<?php
}
}
开发者ID:vstorm83,项目名称:propertease,代码行数:43,代码来源:mailchimp.php
示例16: handleRedirectReturn
public static function handleRedirectReturn($data = false)
{
if (isset($data['error'])) {
return 'There was an error. (general) Please try again.';
} else {
$connections = CASHSystem::getSystemSettings('system_connections');
require_once CASH_PLATFORM_ROOT . '/lib/oauth2/OAuth2Client.php';
require_once CASH_PLATFORM_ROOT . '/lib/oauth2/OAuth2Exception.php';
require_once CASH_PLATFORM_ROOT . '/lib/mailchimp/MC_OAuth2Client.php';
$oauth_options = array('redirect_uri' => $connections['com.mailchimp']['redirect_uri'], 'client_id' => $connections['com.mailchimp']['client_id'], 'client_secret' => $connections['com.mailchimp']['client_secret'], 'code' => $data['code']);
$client = new MC_OAuth2Client($oauth_options);
$session = $client->getSession();
if ($session) {
require_once CASH_PLATFORM_ROOT . '/lib/mailchimp/MailChimp.class.php';
$cn = new MC_OAuth2Client($oauth_options);
$cn->setSession($session, false);
$odata = $cn->api('metadata', 'GET');
$access_token = $session['access_token'];
$api_key = $session['access_token'] . '-' . $odata['dc'];
$api = new MailChimp($api_key);
$lists = $api->call('lists/list');
$return_markup = '<h4>Connect to MailChimp</h4>' . '<p>Now just choose a list and save the connection.</p>' . '<form accept-charset="UTF-8" method="post" action="">' . '<input type="hidden" name="dosettingsadd" value="makeitso" />' . '<input id="connection_name_input" type="hidden" name="settings_name" value="(MailChimp list)" />' . '<input type="hidden" name="settings_type" value="com.mailchimp" />' . '<input type="hidden" name="key" value="' . $api_key . '" />' . '<label for="list">Choose a list to connect to:</label>' . '<select id="list_select" name="list">';
$selected = ' selected="selected"';
$list_name = false;
foreach ($lists['data'] as $list) {
if ($selected) {
$list_name = $list['name'];
}
$return_markup .= '<option value="' . $list['id'] . '"' . $selected . '>' . $list['name'] . '</option>';
$selected = false;
}
$return_markup .= '</select><br /><br />' . '<div><input class="button" type="submit" value="Add The Connection" /></div>' . '</form>' . '<script type="text/javascript">' . '$("#connection_name_input").val("' . $list_name . ' (MailChimp)");' . '$("#list_select").change(function() {' . ' var newvalue = this.options[this.selectedIndex].text + " (MailChimp)";' . ' $("#connection_name_input").val(newvalue);' . '});' . '</script>';
return $return_markup;
} else {
return 'There was an error. (session) Please try again.';
}
}
}
开发者ID:JamesLinus,项目名称:platform,代码行数:38,代码来源:MailchimpSeed.php
示例17: smamo_ajax_newsletter
function smamo_ajax_newsletter()
{
$response = array();
$email = wp_strip_all_tags($_POST['email']);
$name = wp_strip_all_tags($_POST['name']);
$company = wp_strip_all_tags($_POST['company']);
if (!$email || $email === '') {
$response['error'] = 'Indtast venligst en email';
echo json_encode($response);
exit;
}
if (!$name || $name === '') {
$response['error'] = 'Indtast venligst et navn';
echo json_encode($response);
exit;
}
$MailChimp = new MailChimp('ba0b66dc16c9b1243fb3b398438407e7-us11');
$result = $MailChimp->call('lists/subscribe', array('id' => 'f53e3e341b', 'email' => array('email' => $email), 'merge_vars' => array('NAME' => $name, 'COMPANY' => $company), 'double_optin' => true, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => true));
$response['mailchimp'] = $result;
$response['success'] = '<h3>Tjek din indbakke</h3><p>Tak for din tilmelding. Du vil modtage en endelig bekræftelsesmail på den indtastede e-mailadresse.</p>';
echo json_encode($response);
exit;
}
开发者ID:JeppeSigaard,项目名称:fsd,代码行数:23,代码来源:newsletter.php
示例18: jio_ajax_newsletter
function jio_ajax_newsletter()
{
$response = array();
$email = wp_strip_all_tags($_POST['email']);
$name = wp_strip_all_tags($_POST['name']);
if (!$email || $email === '') {
$response['error'] = 'Indtast venligst en email';
echo json_encode($response);
exit;
}
if (!$name || $name === '') {
$response['error'] = 'Indtast venligst et navn';
echo json_encode($response);
exit;
}
$MailChimp = new MailChimp('441ab7ecd918ac4ba432faba058ab24f-us11');
$result = $MailChimp->call('lists/subscribe', array('id' => '3f31ffc20a', 'email' => array('email' => $email), 'merge_vars' => array('NAME' => $name), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
$response['mailchimp'] = $result;
$response['destroy_self'] = '5000';
$response['success'] = '<h2 class="dimitri">Godt Gået!</h2><p>Vi høres ved inden længe. I mellemtiden er du velkommen til at kigge dig omkring her på min blog.</p>';
echo json_encode($response);
exit;
}
开发者ID:JeppeSigaard,项目名称:jeppe-wp-theme,代码行数:23,代码来源:newsletter.php
示例19: signup
/**
* Signup
*
*/
function signup()
{
$opts = get_option($this->option_name);
$opts = $opts[$this->number];
$success = false;
$message = '';
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
try {
$mailchimp = new MailChimp($opts['api_key']);
$response = $mailchimp->call('lists/subscribe', array('email' => array('email' => $email), 'id' => $opts['list_id']));
} catch (Exception $ex) {
$message = __("Sorry! There was an error connecting to Mailchimp'", THEMENAME);
}
if (isset($response['email'])) {
$success = true;
} else {
$message = $response['error'];
}
if (!$success && empty($message)) {
$message = __("Sorry! There was an error in the newsletter configuration, contact the website admin", THEMENAME);
}
echo json_encode(array('success' => $success, 'message' => $message));
die;
}
开发者ID:benedict-w,项目名称:pressgang,代码行数:28,代码来源:mailchimp.php
示例20: ajax
public function ajax()
{
$json = array('msg' => '', 'flag' => 1);
if (is_email($_POST['email'])) {
$response = MailChimp::put(array(array($_POST['email'], '', '')), false, true, true);
if ($response['error_count'] > 0) {
$json['msg'] = self::alert("An error occurred! Sorry, we couldn't sign you on at this point!");
$json['flag'] = 0;
} elseif ($response['add_count'] == 0 && $response['update_count'] == 1) {
$json['msg'] = self::alert("Seems like we already had you on our list!", "warning");
$json['flag'] = 2;
} else {
$json['msg'] = self::alert("Thanks Champ for Subscribing! Exciting stuff coming your way!", "info");
}
} else {
$json['msg'] = self::alert("Invalid email!");
$json['flag'] = 0;
}
echo json_encode($json);
exit;
}
开发者ID:niamhmphelan,项目名称:refugeebnb-wordpress-theme,代码行数:21,代码来源:functions.php
注:本文中的MailChimp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论