« Back to Documentation Overviewfolders – v1.3
folders(string apikey, string type)
List all the folders for a user account
| Parameters | | apikey | a valid API Key for your user account. Get by visiting your API dashboard |
| type | optional - the type of folders to return - either "campaign" or "autoresponder". Defaults to "campaign" |
| Returns | | array |
Array of folder structs (see Returned Fields for details)
| int | folder_id | Folder Id for the given folder, this can be used in the campaigns() function to filter on.
| | string | name | Name of the given folder
| | string | date_created | The date/time the folder was created
| | string | type | The type of the folders being returned, just to make sure you know.
| |
Examples (2)
download example code
[1] mcapi_folders.php
<?php
/**
This Example shows how to pull a list of your Campaign Folders via the MCAPI class.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$retval = $api->folders();
if ($api->errorCode){
echo "Unable to Pull List of Folders or You have not created any!"; echo "\n\tCode=".$api->errorCode; echo "\n\tMsg=".$api->errorMessage."\n"; } else {
echo "No Folders found!\n"; } else {
foreach($retval as $folder){
echo $folder['folder_id'].' => '.$folder['name']."\n"; }
}
}
?>
[2] xml-rpc_folders.php
<?php
/**
This Example shows how to get the list of Campaign Folders you have setup 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->folders($apikey);
foreach($result as $folder){
echo $folder['folder_id'].' - '.$folder['name']."\n"; }
} catch (XML_RPC2_FaultException $e){
echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; }
?>