batchAddContacts
public static array batchAddContacts(string token, string listID, array contacts)
Add the batch of contact details to the given contact list.
Section
Contact List Related Methods

Parameters
string tokenA valid token for your account. To generate a token, use the login method.
string listIDThe contact list ID in which to add contacts. To get all the contact lists, use the listGet method.
array contactsThe array containing the contact details.
string emailThe email address
string firstnameThe First Name of the contact
string lastnameThe Last Name of the contact
string field nameData for that field name
string field nameData for that field name
string field nameData for that field name ...

Returns
stringReturns the batch ID. To check the status use the batchGetStatus method.


Examples
download example code
xmlrpc_batchAddContacts.php


  1. <?php
  2. /**
  3. This Example shows how to authenticate a user using XML-RPC.
  4. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  5. **/
  6. require_once 'XML/RPC2/Client.php';
  7. require_once 'inc/config.php';
  8. $client = XML_RPC2_Client::create($apiURL);
  9. $token = $client->login($apiLogin, $apiPassword);
  10.  
  11. /**
  12. Fetch the latest contact list, so we can retrieve the contact list ID.
  13. **/
  14. $contactList = $client->listGet($token, "", 1, 1, "", "");
  15. $listID = $contactList[0]['id'];
  16. /**
  17. Prepare the data to insert.
  18. **/
  19. for($i = 0; $i < 100 ; $i++) {
  20. $details[$i]['email'] = "user" . $i . "@___.com";
  21. $details[$i]['firstname'] = 'Name' . $i;
  22. $details[$i]['lastname'] = 'Surname' . $i;
  23. $details[$i]['extra 4'] = 'order no' . $i;
  24. }
  25.  
  26. $batchID = $client->batchAddContacts($token, $listID, $details);
  27.  
  28. echo "Batch Id = " . $batchID;
  29. ?>