« Back to Documentation Overview

apikeyAdd – v1.1

 apikeyAdd(string username, string password, string apikey)

Add an API Key to your account. We will generate a new key for you and return it.

Section
Security Related
xml-rpc_apikeyAdd.php
Parameters
username Your MailChimp user name
password Your MailChimp password
apikey Any valid API Key
Returns
string a new API Key that can be immediately used.

Examples (1)

download example code

[1] xml-rpc_apikeyAdd.php

  1. <?php
  2. /**
  3. This Example shows how add an API Key to your account and then retrieve a list
  4. of all API Keys on your account using XML-RPC.
  5. Note that we are using the PEAR XML-RPC2 client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9.  
  10. try {
  11. $client = XML_RPC2_Client::create($apiUrl);
  12.  
  13. $result = $client->apikeyAdd($username,$password, $apikey);
  14. echo "SUCCESS! \n";
  15. echo "New API Key = ".$result."\n";
  16. echo "\n";
  17. echo "All API Keys for your account:\n";
  18. $result = $client->apikeys($username,$password, $apikey);
  19. foreach($result as $key){
  20. echo "key = ".$key['apikey']."\n";
  21. echo "\tcreated: = ".$key['created_at']."\n";
  22. echo "\texpired : = ".$key['expired_at']."\n";
  23. }
  24.  
  25. } catch (XML_RPC2_FaultException $e){
  26. echo "ERROR!!!!\n";
  27. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  28. }
  29.