« Back to Documentation Overview

createFolder – v1.1

 createFolder(string apikey, string name)

Create a new folder to file campaigns in

Section
Helper
Parameters
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard
name a unique name for a folder
Returns
integer the folder_id of the newly created folder.

Examples (2)

download example code

[1] mcapi_createFolder.php

  1. <?php
  2. /**
  3. This Example shows how to send Delete Campaigns 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->createFolder('MyTestFolder');
  11.  
  12. if ($api->errorCode){
  13. echo "Unable to createFolder!";
  14. echo "\n\tCode=".$api->errorCode;
  15. echo "\n\tMsg=".$api->errorMessage."\n";
  16. } else {
  17. echo "Folder created! Id=".$retval."\n";
  18. }
  19.  

[2] xml-rpc_createFolder.php

  1. <?php
  2. /**
  3. This Example shows how execute a ping and check the result using XML-RPC.
  4. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  5. **/
  6. require_once 'XML/RPC2/Client.php';
  7. require_once 'inc/config.inc.php';
  8. try {
  9. $client = XML_RPC2_Client::create($apiUrl);
  10.  
  11. $result = $client->createFolder('MyNewFolder');
  12. echo "Success. New Folder id = ".$result."\n";
  13.  
  14. } catch (XML_RPC2_FaultException $e){
  15. echo "ERROR!!!!\n";
  16. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  17. }
  18.  
  19.