« Back to Documentation OverviewcampaignFolders – v1.2
campaignFolders(string apikey)
List all the folders for a user account
| Parameters | | apikey a valid API Key for your user account. Get by visiting your API dashboard |
| Returns | | array |
Array of folder structs (see Returned Fields for details) |
| Returned Fields | integer | 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 |
Examples (2)
download example code
[1] mcapi_campaignFolders.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->campaignFolders();
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_campaignFolders.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->campaignFolders($apikey);
foreach($result as $folder){
echo $folder['folder_id'].' - '.$folder['name']."\n"; }
} catch (XML_RPC2_FaultException $e){
echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; }
?>