« Back to Documentation Overviewapikeys – v1.1
apikeys(string username, string password, string apikey, boolean expired)
Retrieve a list of all MailChimp API Keys for this User
| Parameters | | username | Your MailChimp user name |
| password | Your MailChimp password |
| apikey | Any valid API Key |
| expired | optional - whether or not to include expired keys, defaults to false |
| Returns | | array |
an array of API keys including: |
| Returned Fields | string | apikey | The api key that can be used | string | created_at | The date the key was created | string | expired_at | The date the key was expired |
Examples (2)
download example code
[1] xml-rpc_apikeyAdd.php
<?php
/**
This Example shows how add an API Key to your account and then retrieve a list
of all API Keys on your account using XML-RPC.
Note that we are using the PEAR XML-RPC2 client and recommend others do as well.
**/
require_once 'XML/RPC2/Client.php';
require_once 'inc/config.inc.php';
try {
$result = $client->apikeyAdd($username,$password, $apikey);
echo "New API Key = ".$result."\n"; echo "All API Keys for your account:\n"; $result = $client->apikeys($username,$password, $apikey);
foreach($result as $key){
echo "key = ".$key['apikey']."\n"; echo "\tcreated: = ".$key['created_at']."\n"; echo "\texpired : = ".$key['expired_at']."\n"; }
} catch (XML_RPC2_FaultException $e){
echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; }
[2] mcapi_apikeyAdd.php
<?php
/**
This Example shows how to add a new API key using the MCAPI.php class and do
some basic error checking.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$retval = $api->apiKeyAdd($username, $password);
if ($api->errorCode){
echo "Unable to load Add a New API Key()!"; echo "\n\tCode=".$api->errorCode; echo "\n\tMsg=".$api->errorMessage."\n"; } else {
echo "New API Key:".$retval."\n"; }