Skip to content

Instantly share code, notes, and snippets.

@mc-doc
Created April 25, 2018 20:27
Show Gist options
  • Save mc-doc/bd569fb6bae6102f6caaf7467533f7b7 to your computer and use it in GitHub Desktop.
Save mc-doc/bd569fb6bae6102f6caaf7467533f7b7 to your computer and use it in GitHub Desktop.
php sample on retrieving_the_email_folder_hierarchy.htm
<?php
echo '<pre>';
$path = $_SERVER[DOCUMENT_ROOT].'/00 Includes/';
require($path . 'exacttarget_soap_client.php');
$wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';
try{
/* Create the Soap Client */
$client = new Marketing CloudSoapClient($wsdl, array('trace'=>1));
/* Set username and password here */
$client->username = XXXXX;
$client->password = XXXXX;
$rr = new Marketing Cloud_RetrieveRequest();
$rr->ObjectType = 'DataFolder';
//Set the properties to return
$props = array("ID", "Name", "ParentFolder.ID","ParentFolder.Name" );
$rr->Properties = $props;
//Setup account filtering, to look for a given account MID
$filterPart = new Marketing Cloud_SimpleFilterPart();
$filterPart->Property = 'ContentType';
$values = array('Email');
$filterPart->Value = $values;
$filterPart->SimpleOperator = Marketing Cloud_SimpleOperators::equals;
//Encode the SOAP package
$filterPart = new SoapVar($filterPart, SOAP_ENC_OBJECT,'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");
//Set the filter to NULL to return all MIDs, otherwise set to filter object
//$rr->Filter = NULL;
$rr->Filter = $filterPart;
//Setup and execute request
$rrm = new Marketing Cloud_RetrieveRequestMsg();
$rrm->RetrieveRequest = $rr;
$results = $client->Retrieve($rrm);
print_r($results);
} catch (SoapFault $e) {
/* output the resulting SoapFault upon an error */
var_dump($e);
}
echo '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment