« Back to Documentation Overview

apikeyExpire – v1.1

 apikeyExpire(string username, string password, string apikey)

Expire a Specific API Key. Note that if you expire all of your keys, a new, valid one will be created and returned next time you call Get by visiting your API dashboard. If you are trying to shut off access to your account for an old developer, change your MailChimp password, then expire all of the keys they had access to. Note that this takes effect immediately, so make sure you replace the keys in any working application before expiring them! Consider yourself warned...

Section
Security Related
Parameters
username Your MailChimp user name
password Your MailChimp password
apikey Any valid API Key that you wish to expire
Returns
boolean true if it worked, otherwise an error is thrown.

Examples (2)

download example code

[1] mcapi_apikeyExpire.php

  1. <?php
  2. /**
  3. This Example shows how to expire an API key using the MCAPI.php class and do
  4. some basic error checking.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $retval = $api->apikeyExpire($username, $password);
  12.  
  13. if ($api->errorCode){
  14. echo "Unable to Expire API Key()!";
  15. echo "\n\tCode=".$api->errorCode;
  16. echo "\n\tMsg=".$api->errorMessage."\n";
  17. } else {
  18. echo "API Key Expired:".$api->api_key."\n";
  19. }
  20.  

[2] xml-rpc_apikeyExpire.php

  1. <?php
  2. /**
  3. This Example shows how to test a List Segment for use with a new campaign using
  4. 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->apikeyExpire($username,$password,$apikey);
  14. echo "SUCCESS! \n";
  15. echo "Returned: ".$result."\n";
  16.  
  17. var_dump($result);
  18.  
  19. } catch (XML_RPC2_FaultException $e){
  20. echo "ERROR!!!!\n";
  21. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  22. }
  23.  
  24.