本文整理汇总了PHP中MailChimp::post方法的典型用法代码示例。如果您正苦于以下问题:PHP MailChimp::post方法的具体用法?PHP MailChimp::post怎么用?PHP MailChimp::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailChimp
的用法示例。
在下文中一共展示了MailChimp::post方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: MailChimp
// 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";
//Making API call, no change needed here
if (!empty($_GET['ajax'])) {
// Validation
if (empty($_GET['email'])) {
echo "No email address provided";
}
if (!preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\$/i", $_GET['email'])) {
echo "Email address is invalid";
}
require_once 'assets/inc/mailchimp/MailChimp.php';
$api = new MailChimp($api_key);
$merge_fields = array('FNAME' => !empty($_GET['fname']) ? $_GET['fname'] : '', 'LNAME' => !empty($_GET['lname']) ? $_GET['lname'] : '');
$result = $api->post("lists/{$list_id}/members", array('email_address' => $_GET['email'], 'status' => 'subscribed', 'merge_fields' => $merge_fields), 100);
if (!empty($result['status']) && $result['status'] === 'subscribed') {
echo 'Success! Check your email to confirm sign up.';
} else {
$message = array();
if (!empty($result['title'])) {
$message[] = $result['title'];
}
if (!empty($result['detail'])) {
$message[] = $result['detail'];
}
echo 'Error: ' . implode(' - ', $message);
}
// After Mailchimp API call executed successfully you can send more emails
// to yourself or users. Just uncomment and edit the code below
/*
示例3: MailChimp
$fs_event = $fs->Api("/events/{$event_json->id}.json");
switch ($fs_event->type) {
case 'install.installed':
$user = $fs_event->objects->user;
$email = $user->email;
$first = $user->first;
$last = $user->last;
/**
* MailChimp SDK for API v3 can be downloaded from here:
* https://github.com/drewm/mailchimp-api
*/
require_once '/path/to/mailchimp-api/api-v3/MailChimp.php';
// Subscribe to mailchimp list.
$blog_subscribers_list = 'LIST_ID';
$mc = new MailChimp('API_KEY');
$result = $mc->post("lists/{$blog_subscribers_list}/members", array('email_address' => $email, 'status' => 'subscribed', 'merge_fields' => array('FNAME' => $first, 'LNAME' => $last)));
break;
case 'install.uninstalled':
$user = $fs_event->objects->user;
$email = $user->email;
$first = $user->first;
$last = $user->last;
$fs_uninstall = $fs->Api("/installs/{$fs_event->objects->install->id}/uninstall.json");
// Send email with your favorite service (we use SendGrid).
define('FS__UNINSTALL_REASON_NO_LONGER_NEEDED', 1);
define('FS__UNINSTALL_REASON_FOUND_BETTER_PLUGIN', 2);
define('FS__UNINSTALL_REASON_USED_FOR_SHORT_PERIOD', 3);
define('FS__UNINSTALL_REASON_BROKE_WEBSITE', 4);
define('FS__UNINSTALL_REASON_STOPPED_WORKING', 5);
define('FS__UNINSTALL_REASON_CANT_CONTINUE_PAYING', 6);
define('FS__UNINSTALL_REASON_OTHER', 7);