Back to Documentation OverviewlistBatchSubscribe
public static listBatchSubscribe(string uid, 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:
| uid | the id for your user account. Get by calling login($user, $pass) |
| id | the list id to connect to |
| 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 |
Examples (1)[1] xml-rpc_listBatchSubscribe.php<?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. **/ require_once 'XML/RPC2/Client.php'; include('inc/config.inc.php'); //contains username & password $client = XML_RPC2_Client::create($apiUrl); $uuid = $client->login($username,$password); $lists = $client->lists($uuid); foreach ($lists as $list){ echo "\n----------------[".$list['id']."]------------\n"; for($i = 0; $i < 2000; $i++){ $batch[] = array("EMAIL"=>$list['id'].'_'.$i.'@nodelivery.com'); } try { /** Note that there is a limit to the number of addresses that can be batch subscribed. Here we are using 2000, which should be fine. We recommend you not attempt to add */ $result = $client->listBatchSubscribe($uuid, $list['id'], $batch, false, false, false); } catch (XML_RPC2_FaultException $e){ echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; } } ?>
|
The documentation confused me a little at first, so here is what I realized:
replace_interests = true: ALL interests provided in call replace all existing interests.
replace_interests = false: Interests provided in call are ADDED to existing interests.
Also note, that the merges[i].name should be set to the .tag. while the LAST merge is used for interests, and so merges[last].name = .name.
Hopefully that will help others.
| |
The name of the array element that holds the returned data that could not be processed is "row", like this:
( [code] => INVALID_EMAIL [message] => Invalid Email Address: tm@dfkjg@.com ( [EMAIL] => tm@dfkjg@.com [EMAIL_TYPE] => html [FNAME] => Torsten [LNAME] => Muller ) )
|
|