当前位置: 首页>>代码示例>>PHP>>正文


PHP MCAPI::listMergeVars方法代码示例

本文整理汇总了PHP中MCAPI::listMergeVars方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listMergeVars方法的具体用法?PHP MCAPI::listMergeVars怎么用?PHP MCAPI::listMergeVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MCAPI的用法示例。


在下文中一共展示了MCAPI::listMergeVars方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mailchimp

function mailchimp()
{
    global $wpdb;
    $mailchimpSettings = $wpdb->get_results("SELECT * FROM wp_options WHERE option_name LIKE '%efreetant_mailchimp_%'", OBJECT);
    $settings = array();
    foreach ($mailchimpSettings as $setting) {
        $settings[$setting->option_name] = $setting->option_value;
    }
    $output['error'] = 0;
    $comm = new MCAPI($settings['efreetant_mailchimp_key']);
    $listvar = $comm->listMergeVars($settings['efreetant_mailchimp_listid']);
    $html = "";
    $html .= '<form action="" method="post" id="mailchimpForm">';
    foreach ($listvar as $var) {
        if ($var['public'] === true && $var['show'] === true) {
            $html .= '<label>' . $var['name'] . '</label>';
            $html .= '<input type="' . $var['field_type'] . '" name="' . $var['tag'] . '" placeholder="' . $var['helptext'] . '" require="' . $var['req'] . '">';
        }
    }
    $html .= '<div class="msgField"></div>';
    $html .= '<input type="hidden" name="action" value="submitmailchimp">';
    $html .= '<p><button type="submit" class="mailchimpBtn">Subscribe</button></p>';
    $html .= '</form>';
    echo $html;
    die;
}
开发者ID:efreetant,项目名称:stellar,代码行数:26,代码来源:ajax.php

示例2: MCAPI

 function get_mailchimp_merge_vars($id)
 {
     require_once PREMISE_LIB_DIR . 'mailchimp_api/MCAPI.class.php';
     $settings = $this->get_settings();
     $mailchimp = new MCAPI($settings['optin']['mailchimp-api']);
     if (!isset($this->_optin_MailChimpMergeVars[$id])) {
         $vars = get_transient('mailchimp_merge_vars_' . $id);
         if (!is_array($vars)) {
             $vars = $mailchimp->listMergeVars($id);
             set_transient('mailchimp_merge_vars_' . $id, $vars, 1 * 60 * 60);
         }
         $this->_optin_MailChimpMergeVars[$id] = $vars;
     }
     return $this->_optin_MailChimpMergeVars[$id];
 }
开发者ID:juslee,项目名称:e27,代码行数:15,代码来源:premise.php

示例3: lists

        trigger_error("Mailchimp API Error calling lists(): " . $api->errorMessage, E_USER_ERROR);
    }
    if (count($lists['data']) == 1) {
        $list_id = $lists['data'][0]['id'];
    }
    if (empty($list_id)) {
        trigger_error("Looked for a single List ID in Mailchimp but couldn't find one", E_USER_NOTICE);
        print_r($lists);
    }
}
if (empty($list_id)) {
    trigger_error("No List ID found - correct your config within " . __FILE__, E_USER_ERROR);
}
// Check that the list has the necessary merge vars
$vars = array();
$vars_res = $api->listMergeVars($list_id);
if (!empty($api->errorMessage)) {
    trigger_error("Mailchimp API Error calling listMergeVars(): " . $api->errorMessage, E_USER_ERROR);
}
foreach ($vars_res as $var_details) {
    $vars[] = $var_details['tag'];
}
$missing_vars = array_diff(array('STATUS', 'CONG', 'AGEBRACKET', 'GENDER'), $vars);
if (!empty($missing_vars)) {
    trigger_error("Your mailchimp list is missing the merge vars " . implode(', ', $missing_vars) . '.  Set these up in Mailchimp then try again.', E_USER_ERROR);
}
// Check that we have a report
if (!(int) $report_id) {
    trigger_error("No Report ID found - correct your config within " . __FILE__, E_USER_ERROR);
}
$report = $GLOBALS['system']->getDBObject('person_query', (int) $report_id);
开发者ID:howardgrigg,项目名称:jethro-pmm,代码行数:31,代码来源:mailchimp_sync.php

示例4: getMailchimpLists

 /**
  * Get all mailchimp list and the fields belongs to them
  */
 public function getMailchimpLists()
 {
     $mailchimp = new MCAPI($this->api_key, $this->ssl);
     // Get Mailchimp lists
     $list_response = $mailchimp->lists();
     if ($mailchimp->errorCode) {
         $this->message = array('text' => $this->l('Mailchimp error code:') . ' ' . $mailchimp->errorCode . '<br />' . $this->l('Milchimp message:') . ' ' . $mailchimp->errorMessage, 'type' => 'error');
         return;
     } else {
         $lists = '';
         foreach ($list_response['data'] as $key => $value) {
             $lists[$key] = $value;
             // Get list fields
             $lists[$key]['fields'] = $mailchimp->listMergeVars($value['id']);
         }
         $this->context->smarty->assign('mailchimp_list', $lists);
         return true;
     }
 }
开发者ID:pedalracer,项目名称:minicmailchimp,代码行数:22,代码来源:minicmailchimp.php

示例5: updateSettings

 function updateSettings($variables)
 {
     if (!isset($variables["mailchimp_secure"])) {
         $variables["mailchimp_secure"] = 0;
     }
     /**
      *   Check for a valid api key.
      */
     if ($variables["apikey_changed"] == "1" && $variables["mailchimp_apikey"] != "") {
         include_once "include/MCAPI.class.php";
         $api = new MCAPI($variables["mailchimp_apikey"]);
         $api->ping();
         if ($api->errorCode) {
             unset($variables["mailchimp_apikey"]);
             $this->updateErrorMessage = "Unable to change the MailChimp apikey: " . $api->errorMessage . " (" . $api->errorCode . ")";
             return $variables;
         }
         //end if
     }
     //end if
     /**
      *  Check for valid list id
      */
     if ($variables["apilist_changed"] == "1" && $variables["mailchimp_list_id"] != "") {
         include_once "include/MCAPI.class.php";
         /**
          *  Check to see if api is already defined (from a possible api key check)
          *  If not, define it and check the key/connection
          */
         if (!isset($api)) {
             $api = new MCAPI($variables["mailchimp_apikey"]);
             $api->ping();
             if ($api->errorCode) {
                 unset($variables["mailchimp_list_id"]);
                 $this->updateErrorMessage = "Unable to change the MailChimp list id: " . $api->errorMessage . " (" . $api->errorCode . ")";
                 return $variables;
             }
             //end if
         }
         //end if
         /**
          *   Look up the lists
          */
         $lists = $api->lists();
         if ($api->errorCode) {
             unset($variables["mailchimp_list_id"]);
             $this->updateErrorMessage = "Unable to change the MailChimp list id: " . $api->errorMessage . " (" . $api->errorCode . ")";
             return $variables;
         } else {
             /**
              *  Check to see if list id is valid
              */
             $validId = false;
             foreach ($lists as $list) {
                 if ($list["id"] == $variables["mailchimp_list_id"]) {
                     $validId = true;
                     break;
                 }
             }
             //endif
             if (!$validId) {
                 unset($variables["mailchimp_list_id"]);
                 $this->updateErrorMessage = "Unable to change the MailChimp list id: the id does not match a valid id on the account.";
                 return $variables;
             } else {
                 /**
                  *  Check to see if the list has a uuid.
                  */
                 $hasUuid = false;
                 $hasCompany = false;
                 $hasType = false;
                 $mergeVars = $api->listMergeVars($variables["mailchimp_list_id"]);
                 if ($api->errorCode) {
                     unset($variables["mailchimp_list_id"]);
                     $this->updateErrorMessage = "Unable to change the MailChimp list id: " . $api->errorMessage . " (" . $api->errorCode . ")";
                     return $variables;
                 }
                 //end if
                 $req = array();
                 foreach ($mergeVars as $mergeVar) {
                     switch ($mergeVar["tag"]) {
                         case "UUID":
                             $hasUuid = true;
                             break;
                         case "COMPANY":
                             $hasCompany = true;
                             break;
                         case "TYPE":
                             $hasType = true;
                             break;
                     }
                     //end switch
                 }
                 //end foreach
                 /**
                  *  If it doesn't have a uuid field, create it.
                  */
                 if (!$hasUuid) {
                     $req = array("req" => true, "public" => false, "field_type" => "text");
                     $api->listMergeVarAdd($variables["mailchimp_list_id"], "UUID", "phpBMS unique user id", $req);
//.........这里部分代码省略.........
开发者ID:Jacquesvw,项目名称:phpBMS,代码行数:101,代码来源:adminsettings.php

示例6: SubscribeAction

 /**
  * Action to process subscriptions
  * @param array $raw_data
  * @param Form $form
  * @return SilverChimpSubscriptionPage_Controller
  */
 function SubscribeAction($raw_data, $form)
 {
     $config = SiteConfig::current_site_config();
     $data = Convert::raw2sql($raw_data);
     // get list of mergeVars to check for from API
     $mergeVars = $this->api->listMergeVars($this->ListID);
     // initialise data container
     $postedVars = array();
     // loop through merge vars and only poopulate data required
     foreach ($mergeVars as $var) {
         if (isset($data[$var['tag']])) {
             $postedVars[$var['tag']] = $data[$var['tag']];
         }
     }
     // get all groups for list
     $groupData = $this->api->listInterestGroupings($this->ListID);
     // get all defaults for list
     $groupDefaults = unserialize($this->DefaultGroupSelections);
     if (is_array($groupData) || $groupData instanceof Traversable) {
         // loop through groups
         foreach ($groupData as $gr) {
             // initialise valiable containing the key for defaults test
             $defaultsName = 'SCG-' . preg_replace('/[^0-9A-Za-z]/', '-', $gr['name']);
             // if a GROUPINGS value for the current group exists
             if (isset($data['GROUPINGS'][$gr['name']])) {
                 $newGroups = array();
                 // check current group is in submitted values
                 foreach ($gr['groups'] as $gd) {
                     if (in_array($gd['bit'], $data['GROUPINGS'][$gr['name']])) {
                         $newGroups[] = $gd['name'];
                     }
                 }
                 // add groups to data for subscription
                 $postedVars['GROUPINGS'][] = array('name' => $gr['name'], 'groups' => implode(',', $newGroups));
             } else {
                 if (isset($groupDefaults[$defaultsName])) {
                     // if defaults present
                     $newGroups = array();
                     // loop through groups and check in defaults
                     foreach ($gr['groups'] as $gd) {
                         if (in_array($gd['bit'], $groupDefaults[$defaultsName])) {
                             $newGroups[] = $gd['name'];
                         }
                     }
                     // add groups to data for subscription
                     $postedVars['GROUPINGS'][] = array('name' => $gr['name'], 'groups' => implode(',', $newGroups));
                 }
             }
         }
     }
     $this->extend('updateSilverChimpSignupAction', $data, $postedVars);
     // send subscription data to MailChimp
     $result = $this->api->listSubscribe($this->ListID, $postedVars['EMAIL'], $postedVars, $config->ChimpEmailType, $config->ChimpDoubleOptIn, $this->AllowUpdateExisting, $config->ChimpReplaceGroups, $config->ChimpSendWelcome);
     if (true === $result) {
         //    success!
         Session::set('SilverChimp.SUCCESS', true);
         return $this->subscribeSuccess();
     } else {
         //    failure!
         $form->sessionMessage($this->api->errorMessage, 'warning');
         return $this;
     }
 }
开发者ID:helpfulrobot,项目名称:zucchi-silverchimp,代码行数:69,代码来源:SilverChimpSubscriptionPage.php

示例7: UpdateLists

 public function UpdateLists()
 {
     $api = new MCAPI($this->apikey);
     $retval = $api->lists();
     if ($api->errorCode) {
         SS_Log::log("Unable to load lists()! Error Code = " . $api->errorCode . " Error Msg = " . $api->errorMessage, SS_Log::ERR);
         return false;
     } else {
         foreach ($retval['data'] as $list) {
             // Get DataList of All MCLists
             $dl = MCList::get();
             $l = $dl->where("ListID = '" . $list['id'] . "'")->first();
             // If the Current Iterations List Object Does Not Yet Exist, Create It
             if (!is_object($l)) {
                 $l = new MCList();
                 $l->setField("ListID", $list['id']);
             }
             // Populate/Overwrite the List Data
             $l->setField("Name", $list['name']);
             $l->setField("WebID", $list['web_id']);
             $l->setField("Subscribed", $list['stats']['member_count']);
             $l->setField("Unsubscribed", $list['stats']['unsubscribe_count']);
             $l->setField("Cleaned", $list['stats']['cleaned_count']);
             $l->write();
             // Add/Delete any New/Removed Merge Tags
             // (Newly Added Merge Tags Will Need Linking/Relating to the Appropriate DB Field Name
             // via Admin -> Setting -> MC Lists -> List Field Relationships)
             $retval = $api->listMergeVars($l->ListID);
             if ($api->errorCode) {
                 SS_Log::log("Unable to load listMergeVars()! Code = " . $api->errorCode . " Msg = " . $api->errorMessage, SS_Log::ERR);
                 return false;
             } else {
                 $currTags = array();
                 foreach ($retval as $mergeTagData) {
                     $currTags[] = $mergeTag = $mergeTagData['tag'];
                     $listField = $l->getComponents("MCListFields", "\"MergeTag\" = '" . $mergeTag . "'")->first();
                     if (empty($listField)) {
                         $lf = new MCListField();
                         $lf->setField("MergeTag", $mergeTag);
                         $lf->write();
                         $l->getComponents("MCListFields")->add($lf);
                     }
                 }
                 // Create DataList of All Existing MC List Fields Which Are No Longer Present In MailChimp (Old Merge Tags) and Delete Them
                 $dl = new DataList("MCListField");
                 $filter = "\"MCListID\" = '" . $l->ID . "' AND \"MergeTag\" NOT IN (" . $this->arrayToCSV($currTags) . ")";
                 SS_Log::log("Cleaning up historical merge fields. MCListField delete filter = '" . $filter . "'", SS_Log::NOTICE);
                 $dl->removeByFilter($filter);
             }
         }
     }
     return true;
 }
开发者ID:quadra-digital,项目名称:silverstripe-mailchimp-module,代码行数:53,代码来源:MCSync.php

示例8: mailchimpSF_setup_page


//.........这里部分代码省略.........
        $user = get_option('mc_username');
        $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>';
开发者ID:JGrubb,项目名称:Almond-Tree,代码行数:67,代码来源:mailchimp.php


注:本文中的MCAPI::listMergeVars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。