listAddContacts
public static integer listAddContacts(string token, string listID, array contacts)
Add the contact details to the given contact list. Multiple contacts would be added if the details has more than one items.
Parameters
|
string token | A valid token for your account. To generate a token, use the login method. |
string listID | The contact list ID in which to add contacts. To get all the contact lists, use the listGet method. |
array contacts | The array containing the contact details.string email | The email address | string firstname | The First Name of the contact | string lastname | The Last Name of the contact |
|
string optin | Optional. "1" - will send a confirmation email before adding the contact to the list. |
Returns |
integer | Returns the total number of contacts which were successfully added. |
- <?php
- /**
- This Example shows how to authenticate a user 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.php';
- $client = XML_RPC2_Client::create($apiURL);
- $token = $client->login($apiLogin, $apiPassword);
-
- /**
- Fetch the latest contact list, so we can retrieve the contact list ID.
- **/
- $contactList = $client->listGet($token, "", 1, 1, "", "");
- $listID = $contactList[0]['id'];
- /**
- Set optin to 1 incase you want to send a confirmation link
- **/
- $optin = "0";
-
- /**
- Prepare the data to insert.
- **/
- $record1['email'] = "user1@___.com";
- $record1['firstname'] = 'Peter';
- $record1['lastname'] = 'Parker';
-
- $record2['email'] = "user2@___.com";
- $record2['firstname'] = 'Bruce';
- $record2['lastname'] = 'Banner';
-
- $rec = array($record1, $record2);
-
- $added = $client->listAddContacts($token, $listID, $rec);
-
- echo $added . " records added.";
- ?>