Back to Documentation Overview
listSubscribe
public static listSubscribe(string uid, string id, string email_address, array merge_vars, string email_type, boolean double_optin)
Subscribe the provided email to a list
- Section:
- List Related
- Parameters:
uid the id for your user account. Get by calling login($user, $pass) id the list id to connect to email_address the email address to subscribe merge_vars array of merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays). Set Interest Groups by passing a field named "INTERESTS" that contains a comma delimited list of Interest Groups to add. email_type optional - email type preference for the email (html or text, defaults to html) double_optin optional - flag to control whether a double opt-in confirmation message is sent, defaults to true - Returns:
- boolean - true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
- <?php
- /**
- This Example shows how to Subscribe a New Member to a List using the MCAPI.php
- class and do some basic error checking.
- **/
- // Include the MailChimp API code. Do Not Edit This!
- include('inc/MCAPI.class.php');
- include('inc/config.inc.php'); //contains username & password
- // Connect to the MailChimp server with the user's credentials.
- /**
- Note that if you are not passing merge_vars, you will still need to
- pass a "blank" array. That should be either:
- $merge_vars = array('');
- - or -
- $merge_vars = '';
- Specifically, this will fail:
- $merge_vars = array();
- Or pass the proper data as below...
- */
- $retval = $acct->listSubscribe( $listId, $new_email, $merge_vars );
- if (!$retval){
- } else {
- //do something useful!
- }
- ?>
- <?php
- /**
- This Example shows how to Subscribe a New Member to a List using the XML-RPC service
- and do some basic error checking.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- include('inc/config.inc.php'); //contains username & password
- $uuid = $client->login($username,$password);
- try {
- // Note that the same blank array() restriction does apply here that
- // applied to the MCAPI example
- } catch (XML_RPC2_FaultException $e){
- }
- ?>
Examples (2)
download example code[1] mcapi_listSubscribe.php
[2] xml-rpc_listSubscribe.php
|
Add New Note
User Contributed Notes for
listSubscribe |
|---|
| No notes, yet... Will you be the first?? |