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


PHP MCAPI::lists方法代码示例

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


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

示例1: oxy_fetch_api_lists

function oxy_fetch_api_lists()
{
    if (isset($_POST['nonce'])) {
        if (wp_verify_nonce($_POST['nonce'], 'oxygenna-fetch-api-lists-nonce')) {
            header('Content-Type: application/json');
            $resp = new stdClass();
            $apikey = $_POST['api_key'];
            $api = new MCAPI($apikey);
            $retval = $api->lists();
            if ($api->errorCode) {
                $resp->status = 'error';
                $resp->message = $api->errorMessage;
            } else {
                $resp->status = 'ok';
                $resp->count = $retval['total'];
                $resp->lists = array();
                foreach ($retval['data'] as $list) {
                    $resp->lists[$list['id']] = $list['name'];
                }
                // we got a new list , so we update the theme options
                global $oxy_theme_options;
                $oxy_theme_options['unregistered']['mailchimp_lists'] = (array) $resp->lists;
                if (isset($oxy_theme_options['unregistered']['mailchimp_lists'])) {
                    $oxy_theme_options['unregistered']['mailchimp_lists'] = (array) $resp->lists;
                } else {
                    $oxy_theme_options['unregistered'] = array('mailchimp_lists' => $resp->lists);
                }
                update_option(THEME_SHORT . '-options', $oxy_theme_options);
            }
            echo json_encode($resp);
            die;
        }
    }
}
开发者ID:vanie3,项目名称:appland,代码行数:34,代码来源:mailchimp.php

示例2: form

	function form($instance) {
		$instance = wp_parse_args( (array) $instance,array( 'title' => "", "list_id" => "") );
		
		$title 		= 	empty($instance['title']) ?	'' : strip_tags($instance['title']);
		$desc 		= 	empty($instance['title']) ?	'' : strip_tags($instance['desc']);
		$list_id 	=	empty($instance['list_id']) ? '' : strip_tags($instance['list_id']);
		
		if( dttheme_option('general','mailchimp-key') ):
			require_once(IAMD_FW."theme_widgets/mailchimp/MCAPI.class.php");
			$mcapi = new MCAPI( dttheme_option('general','mailchimp-key') );
			$lists = $mcapi->lists();?>
            
            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','dt_themes');?> 
               <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>"  
                      type="text" value="<?php echo esc_attr($title); ?>" /></label></p>

            <p><label for="<?php echo $this->get_field_id('desc'); ?>"><?php _e('Description:','dt_themes');?>
               <textarea class="widefat" id="<?php echo $this->get_field_id('desc'); ?>" name="<?php echo $this->get_field_name('desc'); ?>" ><?php echo esc_attr($desc); ?></textarea>	 
               </label></p>
                      
            <p><label for="<?php echo $this->get_field_id('list_id'); ?>"><?php _e('Select List:','dt_themes'); ?></label>
               <select id="<?php echo $this->get_field_id('list_id'); ?>" name="<?php echo $this->get_field_name('list_id'); ?>">
               <?php foreach ($lists['data'] as $key => $value):
			   			$id = $value['id'];
						$name = $value['name'];
						$selected = ( $list_id == $id ) ? ' selected="selected" ' : '';
						echo "<option $selected value='$id'>$name</option>";
					 endforeach;?></select></p>
                      
<?php   else:
			echo "<p>".__("Paste your mailchimp api key in BPanel at General Settings tab",'dt_themes')."</p>";
		endif;
	}
开发者ID:namnguyen2312,项目名称:spa,代码行数:33,代码来源:mailchimp.php

示例3: getCMSFields

 public function getCMSFields()
 {
     $fieldBody = new TextareaField('Body', 'Inhoud');
     $fieldBody->setRows(5);
     $oFields = new FieldList(new TextField('Header', 'Title'), $fieldBody, new TextField('FieldLabelName', 'Dummy text in name field'), new TextField('FieldLabelEmail', 'Dummy text in email field'), new TextField('BtnLabel', 'Button label'));
     if (Config::inst()->get(NewsLetterWidget_Name, NewsLetterWidget_Storage_Sys) == NewsLetterWidget_Storage_Sys_Mailchimp) {
         $fldTextFieldListId = new TextField('MailChimpListID', 'Mailchimp lijst id');
         $sApiKey = Config::inst()->get(NewsLetterWidget_Name, NewsLetterWidget_Storage_Sys_Mailchimp_APIKey);
         if ($sApiKey == null || trim($sApiKey) == '') {
             $oFields->push($fldTextFieldListId);
         } else {
             // fetch lists
             $api = new MCAPI($sApiKey);
             $retval = $api->lists();
             if ($api->errorCode) {
                 //echo "Unable to load lists()!";
                 //echo "\n\tCode=".$api->errorCode;
                 //echo "\n\tMsg=".$api->errorMessage."\n";
             } else {
                 //echo "Lists that matched:".$retval['total']."\n";
                 //echo "Lists returned:".sizeof($retval['data'])."\n";
                 $aOptions = array();
                 foreach ($retval['data'] as $list) {
                     //echo "Id = ".$list['id']." - ".$list['name']."\n";
                     //echo "Web_id = ".$list['web_id']."\n";
                     $aOptions[$list['id']] = $list['name'];
                 }
                 $oFields->push(new DropdownField('MailChimpListID', 'Mailchimp lijst id', $aOptions));
             }
         }
     }
     return $oFields;
 }
开发者ID:hamaka,项目名称:hamaka-widgets,代码行数:33,代码来源:NewsletterWidget.php

示例4: MCAPI

 /**
  * Retrieves the MailChimp API key with the get_valid_mailchimp_key function above, then retrieves the MailChimp lists associated with the retrieved Key.
  *
  * No parameters are required.
  *
  * @return string containing a select box with all MailChimp Lists associated with the API key.  
  * If the API key is no longer valid, return nothing.  This avoids an empty MailChimp List Integration option within the Add / Edit Event dialogs.
  * 
  */
 function get_lists()
 {
     global $wpdb;
     $key = MailChimpController::get_valid_mailchimp_key();
     $listSelection = null;
     $currentMailChimpID = null;
     if (!is_array($key) && !empty($key)) {
         //if the user is editing an existing event, get the previously selected MailChimp List ID
         if ($_REQUEST["action"] == "edit" && $_REQUEST["page"] == "events") {
             $MailChimpRow = $wpdb->get_row("SELECT mailchimp_list_id FROM " . EVENTS_MAILCHIMP_EVENT_REL_TABLE . " WHERE event_id = '{$_REQUEST["event_id"]}'", ARRAY_A);
             if (!empty($MailChimpRow)) {
                 $currentMailChimpID = $MailChimpRow["mailchimp_list_id"];
             }
         }
         $api = new MCAPI($key, 1);
         $lists = $api->lists();
         $listSelection = "<label for='mailchimp-lists'>Select an available list " . apply_filters('espresso_help', 'mailchimp-list-integration') . "</label><select id='mailchimp-lists' name='mailchimp_list_id'>";
         $listSelection .= "<option value='0'>Do not send to MailChimp</option>";
         foreach ($lists["data"] as $listVars) {
             $selected = $listVars["id"] == $currentMailChimpID ? " selected" : "";
             $listSelection .= "<option value='{$listVars["id"]}'{$selected}>{$listVars["name"]}</option>";
         }
         $listSelection .= "</select>";
     }
     return $listSelection;
 }
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:35,代码来源:mailchimp.controller.class.php

示例5: addAction

 public function addAction()
 {
     $api = new MCAPI($this->_apiKey);
     $email = $this->getRequest()->getParam('email');
     $retval = $api->lists();
     if ($api->errorCode) {
         Mage::getSingleton('core/session')->addError($this->__('Error: %s', $api->errorMessage));
     } else {
         /*foreach($retval['data'] as $val) {
               if ($val['name'] === "Prospects") {
                   $prospectListId = $val['id'];
               } elseif ($val['name'] === "Fashion Eyewear Customers") {
                   $customerListId = $val['id'];
               }
           }*/
         $customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('email', $email)->getData();
         $customerId = $customers[0]['entity_id'];
         $orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addFieldToFilter('customer_id', $customerId)->getData();
         if (!empty($orders)) {
             //add to Customer List
             $listId = $this->customerListId;
         } else {
             //add to Prospect list
             $listId = $this->prospectListId;
         }
         $merge_vars = array('FNAME' => $this->getRequest()->getParam('firstname'));
         if ($api->listSubscribe($listId, $email, $merge_vars) === true) {
             Mage::getSingleton('core/session')->addSuccess($this->__('Success! Check your email to confirm sign up.'));
         } else {
             Mage::getSingleton('core/session')->addError($this->__('Error: %s', $api->errorMessage));
         }
     }
     $this->_redirectReferer();
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:34,代码来源:MailchimpController.php

示例6: getOptions

 /**
  * Method to get the field options.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     $app = JFactory::getApplication();
     require_once JPATH_SITE . '/components/com_jms/helpers/MCAPI.class.php';
     require_once JPATH_SITE . '/components/com_jms/helpers/MCauth.php';
     $MCauth = new MCauth();
     // Get the component config/params object.
     $params = JComponentHelper::getParams('com_joomailermailchimpintegration');
     $paramsPrefix = version_compare(JVERSION, '1.6.0', 'ge') ? 'params.' : '';
     $api_key = $params->get($paramsPrefix . 'MCapi');
     if ($MCauth->MCauth()) {
         $api = new MCAPI($api_key);
         $retval = $api->lists();
         if (is_array($retval['data'])) {
             foreach ($retval['data'] as $list) {
                 $options[] = JHTML::_('select.option', $list['id'], JText::_($list['name']));
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:31,代码来源:listid.php

示例7: getList

 public static function getList($params = array())
 {
     require_once OSEMSC_B_LIB . DS . 'MCAPI.class.php';
     $oseMscConfig = oseRegistry::call('msc')->getConfig(null, 'obj');
     $APIKey = $oseMscConfig->mailchimp_api_key;
     $api = new MCAPI($APIKey);
     $lists = $api->lists();
     $data = $lists['data'];
     $items = array();
     $item = array();
     foreach ($data as $value) {
         $item['list_id'] = $value['id'];
         $item['name'] = $value['name'];
         $items[] = $item;
     }
     $result = array();
     if (count($items) < 1) {
         $result['total'] = 0;
         $result['results'] = '';
     } else {
         $result['total'] = count($items);
         $result['results'] = $items;
     }
     return $result;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:25,代码来源:panel.mailchimp.php

示例8: form

    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('title' => "", "list_id" => ""));
        $title = empty($instance['title']) ? '' : strip_tags($instance['title']);
        $list_id = empty($instance['list_id']) ? '' : strip_tags($instance['list_id']);
        if (dt_theme_option('general', 'mailchimp-key')) {
            require_once IAMD_FW . "theme_widgets/mailchimp/MCAPI.class.php";
            $mcapi = new MCAPI(dt_theme_option('general', 'mailchimp-key'));
            $lists = $mcapi->lists();
            ?>
            
            <p><label for="<?php 
            echo $this->get_field_id('title');
            ?>
"><?php 
            _e('Title:', 'iamd_text_domain');
            ?>
 
               <input class="widefat" id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
"  
                      type="text" value="<?php 
            echo esc_attr($title);
            ?>
" /></label></p>
                      
            <p><label for="<?php 
            echo $this->get_field_id('list_id');
            ?>
"><?php 
            _e('Select List:', 'iamd_text_domain');
            ?>
</label>
               <select id="<?php 
            echo $this->get_field_id('list_id');
            ?>
" name="<?php 
            echo $this->get_field_name('list_id');
            ?>
">
               <?php 
            foreach ($lists['data'] as $key => $value) {
                $id = $value['id'];
                $name = $value['name'];
                $selected = $list_id == $id ? ' selected="selected" ' : '';
                echo "<option {$selected} value='{$id}'>{$name}</option>";
            }
            ?>
</select></p>
                      
<?php 
        } else {
            echo "<p>" . __("Paste your mailchimp api key in BPanel at General Settings tab", 'iamd_text_domain') . "</p>";
        }
    }
开发者ID:h3rodev,项目名称:sometheme,代码行数:59,代码来源:mailchimp.php

示例9: moveSubscriber

 public function moveSubscriber()
 {
     $api = new MCAPI($this->_apiKey);
     $retval = $api->lists();
     if ($api->errorCode) {
         Mage::getSingleton('core/session')->addError($this->__('Error: %s', $api->errorMessage));
     } else {
         foreach ($retval['data'] as $val) {
             if ($val['name'] === "Prospects") {
                 $prospectListId = $val['id'];
             } elseif ($val['name'] === "Fashion Eyewear Customers") {
                 $customerListId = $val['id'];
             }
         }
         if ($api->errorCode != '') {
             // an error occurred while logging in
             Mage::log('Error Code: ' . $api->errorCode);
             Mage::log('Error Message: ' . $api->errorMessage);
             die;
         }
         $retval = $api->listMembers($prospectListId, 'subscribed', null, 0, 10000);
         //var_dump($retval);die;
         if (!$retval) {
             Mage::log('Error Code: ' . $api->errorCode);
             Mage::log('Error Message: ' . $api->errorMessage);
         } else {
             foreach ($retval['data'] as $member) {
                 //echo $member['email']." - ".$member['timestamp']."<br />";
                 $customerModel = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('email', $member['email'])->setPage(1, 1);
                 $customers = $customerModel->getData();
                 $customerId = $customers[0]['entity_id'];
                 $orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addFieldToFilter('customer_id', $customerId)->getData();
                 if (!empty($orders)) {
                     //if ($member['email'] === 'ruffian.ua@gmail.com') {
                     $memInfo = $api->listMemberInfo($prospectListId, array($member['email']));
                     $firstname = $memInfo['data'][0]['merges']['FNAME'];
                     if (empty($firstname)) {
                         $firstname = Mage::getModel('customer/customer')->load($customerId)->getFirstname();
                     }
                     $retuns = $api->listUnsubscribe($prospectListId, $member['email'], 1);
                     if (!$retuns) {
                         Mage::log('Unsubscribe Error Code: ' . $api->errorCode);
                         Mage::log('Unsubscribe Error Message: ' . $api->errorMessage);
                     }
                     $merge_vars = array('FNAME' => $firstname);
                     $retsub = $api->listSubscribe($customerListId, $member['email'], $merge_vars);
                     if (!$retsub) {
                         Mage::log('Subscribe Error Code: ' . $api->errorCode);
                         Mage::log('Subscribe Error Message: ' . $api->errorMessage);
                     }
                     //}
                 }
             }
         }
     }
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:56,代码来源:Mailchimp.php

示例10: getMailinglist

 /**
  * Get information about a specific mailing list.
  * 
  * @param string $id The id of the list to get information about.
  * @param bool $useCache If true, use the cached result if available.
  * @return array Array of data about a list.
  * @link MailingList::listMailinglists.
  */
 public function getMailinglist($id, $useCache = true)
 {
     $cacheName = $this->__getCacheName(__FUNCTION__, array($id));
     if ($useCache) {
         $cachedResult = $this->__getCachedResult($cacheName);
         if ($cachedResult !== false) {
             return $cachedResult;
         }
     }
     $result = $this->__api->lists(array('list_id' => $id));
     $this->__cacheResult($cacheName, $result);
     return $result;
 }
开发者ID:JodiWarren,项目名称:hms,代码行数:21,代码来源:MailingList.php

示例11: Mailinglists_subscribe

/**
 * subscribe to a mailinglist
 *
 * @return status
 */
function Mailinglists_subscribe()
{
    $list = (int) $_REQUEST['list'];
    $email = $_REQUEST['email'];
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return array('error' => __('Not an email address'));
    }
    $sql = 'select * from mailinglists_lists';
    if ($list) {
        $sql .= ' where id=' . $list;
    }
    $list = dbRow($sql);
    if (!$list) {
        return array('error' => __('No such mailing list'));
    }
    $listMeta = json_decode($list['meta'], true);
    switch ($listMeta['engine']) {
        case 'Ubivox':
            // {
            $apiusername = $listMeta['ubivox-apiusername'];
            $apipassword = $listMeta['ubivox-apipassword'];
            $listId = preg_replace('/\\|.*/', '', $listMeta['ubivox-list']);
            $response = Mailinglists_xmlrpcClient($apiusername, $apipassword, xmlrpc_encode_request('ubivox.create_subscription', array($email, array($listId), true)));
            $data = xmlrpc_decode(trim($response));
            break;
            // }
        // }
        default:
            // {
            $apikey = $listMeta['mailchimp-apikey'];
            require_once dirname(__FILE__) . '/MCAPI.class.php';
            $api = new MCAPI($apikey);
            $data = $api->lists();
            $api->listSubscribe(preg_replace('/\\|.*/', '', $listMeta['mailchimp-list']), $email);
            if ($api->errorCode) {
                return array('error' => $api->errorCode, 'message' => $api->errorMessage);
            }
            // }
    }
    return array('ok' => true);
}
开发者ID:raylouis,项目名称:kvwebme,代码行数:46,代码来源:api.php

示例12: subscribe_user_to_list

/**
 * Given a user, the name of a MailChimp list, and the MailChimp API credentials,
 * subscribe user to named list. <b>Will die() on any errors from MailChimp.</b>
 *
 * For the MailChimp API documentation pertinent to subscribing a user, see here:
 *  <a href="http://www.mailchimp.com/api/1.0/listsubscribe.func.php">MailChimp
 *  API</a>
 * 
 * @param array $user	Contains the information about the user to subscribe.  Keys:
 *                     'first_name'         => string; the user's first name
 *                     'last_name'          => string; the user's last name
 *                     'email'              => string; the user's email address
 *                     'format'  (optional) => string; list format preference,
 *																							        either 'html' or 'text'
 *                                             If not present, defaults to 'html'.
 *                     'confirm' (optional) => boolean; when true, send a
 *																							subscription confirmation.
 *                                              If not present, defaults to true.
 *
 * @param string $list_name     The name of the list to subscribe to.
 *
 * @param array $credentials    Contains the credentials for the MailChimp account
 *															 that owns the list.  Keys:
 *                               'user'              => string; MailChimp username
 *                               'pass'              => string; MailChimp password
 *
 * @return  boolean             Returns true if member subscribed to the list.
 */
function subscribe_user_to_list($user, $list_name, $credentials)
{
    if (isset($credentials['apikey'])) {
        $credentials['user'] = $credentials['apikey'];
        // With an API key, pass it as the first parameter to the MCAPI constructor.
    }
    $mc = new MCAPI($credentials['user']);
    $mc or die("Unable to connect to MailChimp API, error: " . $mc->errorMessage);
    $lists = $mc->lists() or die($mc->errorMessage);
    $list_id = null;
    foreach ($lists['data'] as $list) {
        // Iterate, finding the list named $list_name
        if ($list['name'] == $list_name) {
            $list_id = $list['id'];
        }
    }
    $list_id or die("Couldn't find a list named '{$list_name}'!");
    $retval = $mc->listSubscribe($list_id, $user['email'], array('FNAME' => $user['first_name'], 'LNAME' => $user['last_name']), isset($user['format']) ? $user['format'] : 'html', isset($user['confirm']) ? $user['confirm'] : true);
    $retval or preg_match("/already subscribed/i", $mc->errorMessage) or die("Unable to load listSubscribe()! " . "MailChimp reported error:\n\tCode=" . $mc->errorCode . "\n\tMsg=" . $mc->errorMessage . "\n");
    return true;
    // All's well.
}
开发者ID:brettflorio,项目名称:fox2chimp,代码行数:50,代码来源:MailChimpUtils.php

示例13: dh_get_mailchimplist

function dh_get_mailchimplist()
{
    $options = array(__('Nothing Found...', DH_DOMAIN));
    if ($mailchimp_api = dh_get_theme_option('mailchimp_api', '')) {
        if (!class_exists('MCAPI')) {
            include_once DHINC_DIR . '/lib/MCAPI.class.php';
        }
        $api = new MCAPI($mailchimp_api);
        $lists = $api->lists();
        if ($api->errorCode) {
            $options = array(__("Unable to load MailChimp lists, check your API Key.", DH_DOMAIN));
        } else {
            if ($lists['total'] == 0) {
                $options = array(__("You have not created any lists at MailChimp", DH_DOMAIN));
            } else {
                $options = array(__('Select a list', DH_DOMAIN));
                foreach ($lists['data'] as $list) {
                    $options[$list['id']] = $list['name'];
                }
            }
        }
    }
    return $options;
}
开发者ID:mysia84,项目名称:mnassalska,代码行数:24,代码来源:functions.php

示例14: getMailChimpLists

 function getMailChimpLists()
 {
     require_once PREMISE_LIB_DIR . 'mailchimp_api/MCAPI.class.php';
     $settings = $this->getSettings();
     $mailchimp = new MCAPI($settings['optin']['mailchimp-api']);
     $data = $mailchimp->lists(array(), 0, 100);
     $lists = array();
     if (is_array($data) && is_array($data['data'])) {
         foreach ($data['data'] as $item) {
             $lists[] = array('id' => $item['id'], 'name' => $item['name']);
         }
     }
     return $lists;
 }
开发者ID:juslee,项目名称:e27,代码行数:14,代码来源:class-premise.php

示例15: MCAPI

                      </div>
 
                      <div class="hr"></div>
                      <div class="clear"> </div>

                      <h6><?php 
_e('Select Mailchimp List', 'dt_themes');
?>
</h6>
                      <div class="column one-half">

                        <?php 
$list_id = dttheme_option('general', 'mailchimp-listid') != '' ? dttheme_option('general', 'mailchimp-listid') : '';
require_once IAMD_FW . "theme_widgets/mailchimp/MCAPI.class.php";
$mcapi = new MCAPI(dttheme_option('general', 'mailchimp-key'));
$lists = $mcapi->lists();
?>

                        <select id="mytheme-mailchimp-listid" name="mytheme[general][mailchimp-listid]">
                        <?php 
foreach ($lists['data'] as $key => $value) {
    $id = $value['id'];
    $name = $value['name'];
    $selected = $list_id == $id ? ' selected="selected" ' : '';
    echo "<option {$selected} value='{$id}'>{$name}</option>";
}
?>
                        </select>                         
                        
                      </div>
                      <div class="column one-half last">
开发者ID:enlacee,项目名称:anb.platicom.com.pe,代码行数:31,代码来源:general.php


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