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


PHP MCAPI::listInterestGroupings方法代码示例

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


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

示例1: getGroups

 /**
  * Get Mailchimp email groups
  *
  * @param   \Joomla\Registry\Registry  $params  Params
  *
  * @throws RuntimeException
  *
  * @return  array groups
  */
 protected function getGroups($params)
 {
     $listId = $params->get('mailchimp_listid');
     $apiKey = $params->get('mailchimp_apikey');
     if ($apiKey == '') {
         throw new RuntimeException('Mailchimp: no api key specified');
     }
     if ($listId == '') {
         throw new RuntimeException('Mailchimp: no list id specified');
     }
     $api = new MCAPI($params->get('mailchimp_apikey'));
     $groups = $api->listInterestGroupings($listId);
     return $groups;
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:23,代码来源:mailchimp.php

示例2: get_interest_groupings

 /**
  * get_interest_groupings function.
  *
  * @access public
  * @return void
  */
 public function get_interest_groupings($listid = 'false')
 {
     if ($listid == 'false') {
         $listid = $this->list;
     }
     $interest_groupings = array();
     $interest_groups = array();
     $api = new MCAPI($this->api_key);
     $retval = $api->listInterestGroupings($listid);
     if ($mailchimp->errorCode) {
         echo $this->get_message(sprintf(__('Unable to load listInterestGroupings() from MailChimp: (%s) %s', 'ss_wc_mailchimp'), $mailchimp->errorCode, $mailchimp->errorMessage));
         return false;
     } else {
         if (sizeof($retval) > 0) {
             foreach ($retval as $interest_grouping) {
                 $interest_groupings[$interest_grouping['id']] = $interest_grouping['name'];
                 foreach ($interest_grouping['groups'] as $group) {
                     $interest_groups[$group['bit']] = $group['name'];
                 }
             }
             if (sizeof($interest_groupings) > 0) {
                 // set transients for cache
                 set_transient('wc_mailchimp_list_' . md5($this->api_key) . '_' . $listid, $interest_groupings, 60 * 60 * 1);
                 set_transient('wc_mailchimp_list_' . md5($this->api_key) . '_' . $listid . '_groups', $interest_groups, 60 * 60 * 1);
                 $this->interest_groupings = $interest_groupings;
                 $this->groups[$listid] = $interest_groups;
             }
         }
     }
     return $interest_groupings;
 }
开发者ID:Inteleck,项目名称:hwc,代码行数:37,代码来源:class-ss-wc-integration-mailchimp.php

示例3: listInterestGroupings

 /**
  * Efficient wrapper for MCAPI:listInterestGroupings()
  * @see application/libraries/MCAPI#listInterestGroupings()
  */
 function listInterestGroupings($id)
 {
     if (isset($this->lists_groups[$id])) {
         return $this->lists_groups[$id];
     }
     return parent::listInterestGroupings($id);
 }
开发者ID:relwell,项目名称:PHP-Point-Of-Sale,代码行数:11,代码来源:MailChimp.php

示例4: 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

示例5: addUserToList

 function addUserToList($user_id, $product_id)
 {
     require_once JPATH_COMPONENT . '/helpers/MCAPI.class.php';
     $db = JFactory::getDBO();
     $sql = "select p.mailchimpapi, p.mailchimplist, p.mailchimpregister, p.mailchimpgroupid, u.email, c.firstname, c.lastname from #__users u, #__digicom_products p, #__digicom_customers c where u.id=c.id and u.id=" . intval($user_id) . " and p.id=" . intval($product_id);
     $db->setQuery($sql);
     $db->query();
     $result = $db->loadAssocList();
     if (isset($result) && count($result) > 0) {
         $mc_username = $result["0"]["mailchimpapi"];
         $mc_listid = $result["0"]["mailchimplist"];
         $mc_autoregister = $result["0"]["mailchimpregister"] == 0 ? FALSE : TRUE;
         $mc_groupid = $result["0"]["mailchimpgroupid"];
         $mc_email = $result["0"]["email"];
         if (trim($mc_username) == "") {
             $sql = "select `mailchimpapi` from #__digicom_settings";
             $db->setQuery($sql);
             $db->query();
             $mc_username = $db->loadResult();
         }
         if (trim($mc_listid) == "") {
             $sql = "select `mailchimplist` from #__digicom_settings";
             $db->setQuery($sql);
             $db->query();
             $mc_listid = $db->loadResult();
         }
         if (trim($mc_username) != "" && trim($mc_listid) != "") {
             $api = new MCAPI($mc_username);
             $user_info = $api->listMemberInfo($mc_listid, $mc_email);
             if ($user_info === FALSE) {
                 //add new user
                 $mergeVars = array('FNAME' => $result["0"]["firstname"], 'LNAME' => $result["0"]["lastname"]);
                 if (trim($mc_groupid) != "") {
                     $mergeVars["INTERESTS"] = trim($mc_groupid);
                 }
                 $api->listSubscribe($mc_listid, $mc_email, $mergeVars, 'html', $mc_autoregister, true);
             } else {
                 //already exist and update user group
                 if (trim($mc_groupid) != "") {
                     $user_group_string = $user_info["merges"]["INTERESTS"];
                     $user_group_array = explode(",", $user_group_string);
                     $exist = FALSE;
                     foreach ($user_group_array as $key => $group) {
                         if (trim($group) == trim($mc_groupid)) {
                             $exist = TRUE;
                         }
                     }
                     if ($exist === FALSE) {
                         $new_group_list = trim($user_group_string);
                         if (trim($new_group_list) != "") {
                             $new_group_list = trim($user_group_string) . ", " . trim($mc_groupid);
                         } else {
                             $new_group_list = trim($mc_groupid);
                         }
                         $mergeVars = array('INTERESTS' => $new_group_list);
                         $name = "";
                         $groups = $api->listInterestGroupings($mc_listid);
                         if (isset($groups) && count($groups) > 0) {
                             foreach ($groups as $key_group => $group) {
                                 if (isset($group["groups"]) && count($group["groups"]) > 0) {
                                     foreach ($group["groups"] as $key_subgroup => $subgroup) {
                                         if (trim($subgroup["name"]) == trim($mc_groupid)) {
                                             $name = $group["name"];
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                         if (trim($name) != "") {
                             $mergeVars = array('INTERESTS' => $new_group_list, 'GROUPINGS' => array(array('name' => $name, 'groups' => $new_group_list)));
                         }
                         $api->listUpdateMember($mc_listid, $mc_email, $mergeVars, 'html', false);
                     }
                 }
             }
         }
     }
 }
开发者ID:Shtier,项目名称:digicom,代码行数:79,代码来源:checkout.php


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