This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 142
/
sample-folder.php
executable file
·151 lines (133 loc) · 7.39 KB
/
sample-folder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
include_once('tests/UnitBootstrap.php');
use FuelSdk\ET_Client;
use FuelSdk\ET_Folder;
try {
$myclient = new ET_Client();
// Retrieve All Folder with GetMoreResults
print "Retrieve All Folder with GetMoreResults \n";
$getFolder = new ET_Folder();
$getFolder->authStub = $myclient;
$getFolder->props = array("ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy");
$getResponse = $getFolder->get();
print_r('Get Status: '.($getResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$getResponse->code."\n";
print 'Message: '.$getResponse->message."\n";
print_r('More Results: '.($getResponse->moreResults ? 'true' : 'false')."\n");
print 'Results Length: '. count($getResponse->results)."\n";
print "\n---------------\n";
while ($getResponse->moreResults) {
print "Continue Retrieve All Folder with GetMoreResults \n";
$getResponse = $getFolder->GetMoreResults();
print_r('Get Status: '.($getResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$getResponse->code."\n";
print 'Message: '.$getResponse->message."\n";
print_r('More Results: '.($getResponse->moreResults ? 'true' : 'false')."\n");
print 'Results Length: '. count($getResponse->results)."\n";
print "\n---------------\n";
}
$NameOfTestFolder = "PHPSDKFolder";
// Retrieve Specific Folder for Email Folder ParentID
print "Retrieve Specific Folder for Email Folder ParentID \n";
$getFolder = new ET_Folder();
$getFolder->authStub = $myclient;
$getFolder->props = array("ID");
$getFolder->filter = array('LeftOperand' => array('Property' => 'ParentFolder.ID','SimpleOperator' => 'equals','Value' => '0'), 'LogicalOperator' => 'AND', 'RightOperand' => array('Property' => 'ContentType','SimpleOperator' => 'equals','Value' => 'EMAIL'));
$getResponse = $getFolder->get();
print_r('Get Status: '.($getResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$getResponse->code."\n";
print 'Message: '.$getResponse->message."\n";
print_r('More Results: '.($getResponse->moreResults ? 'true' : 'false')."\n");
print 'Results Length: '. count($getResponse->results)."\n";
print "\n---------------\n";
$ParentIDForEmail = $getResponse->results[0]->ID;
print_r('Parent Folder for Email: '.$ParentIDForEmail."\n");
// Create Folder
print "Create Folder \n";
$postFolder = new ET_Folder();
$postFolder->authStub = $myclient;
$postFolder->props = array("CustomerKey" => $NameOfTestFolder, "Name" => $NameOfTestFolder, "Description" => $NameOfTestFolder, "ContentType"=> "EMAIL", "ParentFolder" => array("ID" => $ParentIDForEmail));
$postResult = $postFolder->post();
print_r('Post Status: '.($postResult->status ? 'true' : 'false')."\n");
print 'Code: '.$postResult->code."\n";
print 'Message: '.$postResult->message."\n";
print 'Results Length: '. count($postResult->results)."\n";
print 'Results: '."\n";
print_r($postResult->results);
print "\n---------------\n";
// Retrieve newly created Folder
print "Retrieve newly created Folder \n";
$getFolder = new ET_Folder();
$getFolder->authStub = $myclient;
$getFolder->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestFolder);
$getFolder->props = array("ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy");
$getResponse = $getFolder->get();
print_r('Get Status: '.($getResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$getResponse->code."\n";
print 'Message: '.$getResponse->message."\n";
print_r('More Results: '.($getResponse->moreResults ? 'true' : 'false')."\n");
print 'Results Length: '. count($getResponse->results)."\n";
print 'Results: '."\n";
print_r($getResponse->results);
print "\n---------------\n";
// Update Folder
print "Update Folder \n";
$subPatch = new ET_Folder();
$subPatch->authStub = $myclient;
$subPatch->props = array("CustomerKey" => $NameOfTestFolder, "Description" => "New Description");
$patchResult = $subPatch->patch();
print_r('Patch Status: '.($patchResult->status ? 'true' : 'false')."\n");
print 'Code: '.$patchResult->code."\n";
print 'Message: '.$patchResult->message."\n";
print 'Results Length: '. count($patchResult->results)."\n";
print 'Results: '."\n";
print_r($patchResult->results);
print "\n---------------\n";
// Retrieve Updated Folder
print "Retrieve Updated Folder \n";
$getFolder = new ET_Folder();
$getFolder->authStub = $myclient;
$getFolder->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestFolder);
$getFolder->props = array("ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy");
$getResponse = $getFolder->get();
print_r('Get Status: '.($getResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$getResponse->code."\n";
print 'Message: '.$getResponse->message."\n";
print_r('More Results: '.($getResponse->moreResults ? 'true' : 'false')."\n");
print 'Results Length: '. count($getResponse->results)."\n";
print 'Results: '."\n";
print_r($getResponse->results);
print "\n---------------\n";
// Delete Folder
print "Delete Folder \n";
$deleteFolder = new ET_Folder();
$deleteFolder->authStub = $myclient;
$deleteFolder->props = array("CustomerKey" => $NameOfTestFolder);
$deleteResponse = $deleteFolder->delete();
print_r('Delete Status: '.($deleteResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$deleteResponse->code."\n";
print 'Message: '.$deleteResponse->message."\n";
print 'Results Length: '. count($deleteResponse->results)."\n";
print 'Results: '."\n";
print_r($deleteResponse->results);
print "\n---------------\n";
// Retrieve Folder to confirm deletion
print "Retrieve Folder to confirm deletion \n";
$getFolder = new ET_Folder();
$getFolder->authStub = $myclient;
$getFolder->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestFolder);
$getFolder->props = array("ID");
$getResponse = $getFolder->get();
print_r('Get Status: '.($getResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$getResponse->code."\n";
print 'Message: '.$getResponse->message."\n";
print_r('More Results: '.($getResponse->moreResults ? 'true' : 'false')."\n");
print 'Results Length: '. count($getResponse->results)."\n";
print 'Results: '."\n";
print_r($getResponse->results);
print "\n---------------\n";
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>