function MCAPI::listSubscribe in Mailchimp 7
Same name and namespace in other branches
- 5.2 MCAPI.class.php \MCAPI::listSubscribe()
- 5 MCAPI.class.php \MCAPI::listSubscribe()
- 6.2 MCAPI.class.php \MCAPI::listSubscribe()
- 6 MCAPI.class.php \MCAPI::listSubscribe()
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!
Related
@example mcapi_listSubscribe.php @example xml-rpc_listSubscribe.php
Parameters
string $id the list id to connect to. Get by calling lists():
string $email_address the email address to subscribe:
array $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. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must not be a private IP address.
<strong>Handling Field Data Types</strong> - most fields you can just pass a string and all is well. For some, though, that is not the case... Field values should be formatted as follows: string address For the string version of an Address, the fields should be delimited by <strong>2</strong> spaces. Address 2 can be skipped. The Country should be a 2 character ISO-3166-1 code and will default to your default country if not set array address For the array version of an Address, the requirements for Address 2 and Country are the same as with the string version. Then simply pass us an array with the keys <strong>addr1</strong>, <strong>addr2</strong>, <strong>city</strong>, <strong>state</strong>, <strong>zip</strong>, <strong>country</strong> and appropriate values for each
string date use YYYY-MM-DD to be safe. Generally, though, anything strtotime() understands we'll understand - <a href="http://us2.php.net/strtotime" target="_blank">http://us2.php.net/strtotime</a> string dropdown can be a normal string - we <em>will</em> validate that the value is a valid option string image must be a valid, existing url. we <em>will</em> check its existence string multi_choice can be a normal string - we <em>will</em> validate that the value is a valid option double number pass in a valid number - anything else will turn in to zero (0). Note, this will be rounded to 2 decimal places string phone If your account has the US Phone numbers option set, this <em>must</em> be in the form of NPA-NXX-LINE (404-555-1212). If not, we assume an International number and will simply set the field with what ever number is passed in. string website This is a standard string, but we <em>will</em> verify that it looks like a valid URL
string $email_type optional - email type preference for the email (html, text, or mobile defaults to html):
boolean $double_optin optional - flag to control whether a double opt-in confirmation message is sent, defaults to true. <em>Abusing this may cause your account to be suspended.</em>:
boolean $update_existing optional - flag to control whether a existing subscribers should be updated instead of throwing and error:
boolean $replace_interests - flag to determine whether we replace the interest groups with the groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true):
boolean $send_welcome - if your double_optin is false and this is true, we will send your lists Welcome Email if this subscribe succeeds - this will *not* fire if we end up updating an existing subscriber. defaults to false:
Return value
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)
File
- ./
MCAPI.class.php, line 1173
Class
Code
function listSubscribe($id, $email_address, $merge_vars, $email_type = 'html', $double_optin = true, $update_existing = false, $replace_interests = true, $send_welcome = false) {
$params = array();
$params["id"] = $id;
$params["email_address"] = $email_address;
$params["merge_vars"] = $merge_vars;
$params["email_type"] = $email_type;
$params["double_optin"] = $double_optin;
$params["update_existing"] = $update_existing;
$params["replace_interests"] = $replace_interests;
$params["send_welcome"] = $send_welcome;
return $this
->callServer("listSubscribe", $params);
}