« Back to Documentation Overview

campaignFolders – v1.1

 campaignFolders(string apikey)

List all the folders for a user account

Section
Campaign Related
Parameters
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard
Returns
array Array of folder structs (see Returned Fields for details)
Returned Fields
integerfolder_idFolder Id for the given folder, this can be used in the campaigns() function to filter on.
stringnameName of the given folder

Examples (2)

download example code

[1] mcapi_campaignFolders.php

  1. <?php
  2. /**
  3. This Example shows how to pull a list of your Campaign Folders via the MCAPI class.
  4. **/
  5. require_once 'inc/MCAPI.class.php';
  6. require_once 'inc/config.inc.php'; //contains apikey
  7.  
  8. $api = new MCAPI($apikey);
  9.  
  10. $retval = $api->campaignFolders();
  11.  
  12. if ($api->errorCode){
  13. echo "Unable to Pull List of Folders or You have not created any!";
  14. echo "\n\tCode=".$api->errorCode;
  15. echo "\n\tMsg=".$api->errorMessage."\n";
  16. } else {
  17. if (sizeof($retval)==0){
  18. echo "No Folders found!\n";
  19. } else {
  20. echo "Your Folders:\n";
  21. foreach($retval as $folder){
  22. echo $folder['folder_id'].' => '.$folder['name']."\n";
  23. }
  24. }
  25. }
  26.  

[2] xml-rpc_campaignFolders.php

  1. <?php
  2. /**
  3. This Example shows how to get the list of Campaign Folders you have setup on
  4. 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->campaignFolders($apikey);
  14. echo "SUCCESS! \n";
  15. foreach($result as $folder){
  16. echo $folder['folder_id'].' - '.$folder['name']."\n";
  17. }
  18. } catch (XML_RPC2_FaultException $e){
  19. echo "ERROR!!!!\n";
  20. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  21. }
  22.