Back to Documentation Overview
listSubscribe
public static listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin)
Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
- Section:
- List Related
- Parameters:
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard id the list id to connect to. Get by calling lists() 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). Note that a merge field can only hold up to 255 characters. Also, there are 2 "special" keys: string INTERESTS Set Interest Groups by passing a field named "INTERESTS" that contains a comma delimited list of Interest Groups to add. Commas in Interest Group names should be escaped with a backslash. ie, "," => "\," string OPTINIP Set the Opt-in IP fields. Abusing this may cause your account to be suspended. 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. Abusing this may cause your account to be suspended. - 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.
- **/
- require_once 'inc/MCAPI.class.php';
- require_once 'inc/config.inc.php'; //contains apikey
- /**
- 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...
- */
- 'INTERESTS'=>'');
- // By default this sends a confirmation email - you will not see new members
- // until the link contained in it is clicked!
- $retval = $api->listSubscribe( $listId, $my_email, $merge_vars );
- if ($api->errorCode){
- } else {
- }
- <?php
- /**
- This Example shows how to Subscribe a New Member to a List using XML-RPC.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- require_once 'inc/config.inc.php';
- try {
- // Note that the same blank array() restriction for the merge_vars
- // does not apply here as XML-RPC will handle it unless you use a null value
- 'INTERESTS'=>'Dogs,Horses');
- // By default this sends a confirmation email - you will not see new members
- // until the link contained in it is clicked!
- $result = $client->listSubscribe($apikey, $listId, $my_email, $merges, 'html', false);
- } 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?? |