Back to Documentation Overview
listBatchSubscribe
public static listBatchSubscribe(string apikey, string id, array batch, boolean double_optin, boolean update_existing, boolean replace_interests)
Subscribe a batch of email addresses to a list at once
- Section:
- List Related
- Parameters:
apikey a valid API Key for your user account. Get by calling login() id the list id to connect to. Get by calling lists() batch an array of structs for each address to import with two special keys: "EMAIL" for the email address, and "EMAIL_TYPE" for the email type option (html or text) double_optin flag to control whether to send an opt-in confirmation email - defaults to true update_existing flag to control whether to update members that are already subscribed to the list or to return an error, defaults to false (return error) replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true) - Returns:
- struct - Array of result counts and any errors that occurred
- Returned Fields:
integer success_count Number of email addresses that were succesfully added/updated integer error_count Number of email addresses that failed during addition/updating array errors Array of error structs. Each error struct will contain "code", "message", and the full struct that failed - <?php
- /**
- This Example shows how to run a Batch Subscribe on a List using the MCAPI.php
- class and do some basic error checking or handle the return values.
- **/
- require_once 'inc/MCAPI.class.php';
- require_once 'inc/config.inc.php'; //contains apikey
- $optin = true; //yes, send optin emails
- $up_exist = true; // yes, update currently subscribed users
- $replace_int = false; // no, add interest, don't replace
- $vals = $api->listBatchSubscribe($listId,$batch,$optin, $up_exist, $replace_int);
- if ($api->errorCode){
- } else {
- foreach($vals['errors'] as $val){
- }}
- ?>
- <?php
- /**
- This Example shows how to use the XML-RPC service to Batch Subscribe many emails
- to each of your Lists and do some basic error checking.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- Realize that these emails are bogus and being generated - you should not do
- that, especially if you turn on the opt-in email.
- **/
- require_once 'XML/RPC2/Client.php';
- require_once 'inc/config.inc.php';
- try {
- $lists = $client->lists($apikey);
- foreach ($lists as $list){
- for($i = 0; $i < 20; $i++){
- }
- /**
- Note that there is a limit to the number of addresses that can be batch
- subscribed. Here we are using 20, which should be fine. We recommend you
- not attempt to add more than 5000-10,000 addresses per call to
- */
- $result = $client->listBatchSubscribe($apikey, $list['id'], $batch, false, false, false);
- foreach($result['errors'] as $err){
- }
- }
- } catch (XML_RPC2_FaultException $e){
- }
- ?>
Examples (2)
download example code[1] mcapi_listBatchSubscribe.php
[2] xml-rpc_listBatchSubscribe.php
|
Add New Note
User Contributed Notes for
listBatchSubscribe |
|---|
| No notes, yet... Will you be the first?? |