本文整理汇总了PHP中MCAPI::listInterestGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listInterestGroups方法的具体用法?PHP MCAPI::listInterestGroups怎么用?PHP MCAPI::listInterestGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::listInterestGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMemberMailingListSubscriptionInfo
public function getMemberMailingListSubscriptionInfo()
{
/*
* Get MailChimp subscription info for member by email address, or blank info for new member.
* Returns an array including a 'subscribed' flag
* and, (if that's true,) an array of all Interest Groups,
* each with a flag signifying whether the member is subscribed:
* (
* subscribed => bool,
* groups => (
* 'group1' => bool,
* 'group2' => bool,
* 'groupN' => bool
* )
* )
* OR returns an error string.
*/
require_once 'mailchimp-api/MCAPI.class.php';
require_once 'mailchimp-api/config.inc.php';
$mc_api = new MCAPI($mailchimp_api_key);
// Get all Interest Groups
$mc_interest_groups = $mc_api->listInterestGroups($mailchimp_list_id);
if ($mc_api->errorCode) {
return "MailChimp Error (getting groups): " . $mc_api->errorMessage . " (Code: " . $mc_api->errorCode . ")";
}
// Init the return structure
$mc_member_subscription_info = array('subscribed' => false, 'groups' => array());
foreach ($mc_interest_groups['groups'] as $group) {
$mc_member_subscription_info['groups'][$group] = false;
}
$unsubscribed_info = $mc_member_subscription_info;
if ($this->data->id == 0) {
// New member; non-subscribed
return print_r($this, true);
return $unsubscribed_info;
} else {
// Existing member
$email = $this->emailAddress;
// (empty() doesn't seem to take class member as param)
if (empty($email)) {
return "Member e-mail address ('{$this->emailAddress}') invalid; no subscription information possible.";
}
// Get member info in MailChimp
$mc_list_member_info = $mc_api->listMemberInfo($mailchimp_list_id, $this->emailAddress);
if ($mc_api->errorCode) {
switch ($mc_api->errorCode) {
case 215:
// List_NotSubscribed
// List_NotSubscribed
case 232:
// Email_NotExists
// Email_NotExists
case 233:
// Email_NotSubscribed
// Member not yet subscribed.
return $unsubscribed_info;
default:
return "MailChimp Error (getting member info): " . $mc_api->errorMessage . " (Code: " . $mc_api->errorCode . ")";
}
}
$mc_member_subscription_info['subscribed'] = $mc_list_member_info['status'] == 'subscribed';
// subscribed groups
$mc_groups_list_str = $mc_list_member_info['merges']['INTERESTS'];
$mc_member_groups = explode(', ', $mc_groups_list_str);
foreach ($mc_member_groups as $group) {
if (isset($mc_member_subscription_info['groups'][$group])) {
$mc_member_subscription_info['groups'][$group] = true;
}
}
}
return $mc_member_subscription_info;
}
示例2: mailchimpSF_setup_page
//.........这里部分代码省略.........
$pass = get_option('mc_password');
}
if (get_option('mc_apikey') != '') {
$GLOBALS["mc_api_key"] = get_option('mc_apikey');
$api = new MCAPI('no_login', 'is_needed');
$lists = $api->lists();
foreach ($lists as $list) {
if ($list['id'] == $_REQUEST['mc_list_id']) {
$list_id = $_REQUEST['mc_list_id'];
$list_name = $list['name'];
}
}
$orig_list = get_option('mc_list_id');
if ($list_id != '') {
update_option('mc_list_id', $list_id);
update_option('mc_list_name', $list_name);
if ($orig_list != $list_id) {
update_option('mc_header_content', __('Sign up for', 'mailchimp_i18n') . ' ' . $list_name);
update_option('mc_submit_text', __('Subscribe', 'mailchimp_i18n'));
update_option('mc_custom_style', 'on');
update_option('mc_use_javascript', 'on');
update_option('mc_use_unsub_link', 'off');
update_option('mc_header_border_width', '1');
update_option('mc_header_border_color', 'E3E3E3');
update_option('mc_header_background', 'FFFFFF');
update_option('mc_header_text_color', 'CC6600');
update_option('mc_form_border_width', '1');
update_option('mc_form_border_color', 'C4D3EA');
update_option('mc_form_background', 'EEF3F8');
update_option('mc_form_text_color', '555555');
update_option('mc_show_interest_groups', 'on');
}
$mv = $api->listMergeVars($list_id);
$ig = $api->listInterestGroups($list_id);
update_option('mc_merge_vars', serialize($mv));
foreach ($mv as $var) {
$opt = 'mc_mv_' . $var['tag'];
//turn them all on by default
if ($orig_list != $list_id) {
update_option($opt, 'on');
}
}
update_option('mc_interest_groups', serialize($ig));
$msg = '<span class="success_msg">' . sprintf(__('Success! Loaded and saved the info for %d Merge Variables and %d Interest Groups from your list'), sizeof($mv), sizeof($ig)) . ' "' . $list_name . '"<br/><br/>' . __('Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.', 'mailchimp_i18n') . '</span>';
}
}
if (isset($_REQUEST['reset_list'])) {
delete_option('mc_list_id');
delete_option('mc_list_name');
delete_option('mc_merge_vars');
delete_option('mc_interest_groups');
delete_option('mc_use_javascript');
delete_option('mc_use_unsub_link');
delete_option('mc_header_content');
delete_option('mc_submit_text');
delete_option('mc_custom_style');
delete_option('mc_header_border_width');
delete_option('mc_header_border_color');
delete_option('mc_header_background');
delete_option('mc_header_text_color');
delete_option('mc_form_border_width');
delete_option('mc_form_border_color');
delete_option('mc_form_background');
delete_option('mc_form_text_color');
$msg = '<span class="success_msg">' . __('Successfully Reset your List selection... Now you get to pick again!', 'mailchimp_i18n') . '</span>';
}