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-contentarea.php
executable file
·134 lines (118 loc) · 5.97 KB
/
sample-contentarea.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
<?php
include_once('tests/UnitBootstrap.php');
use FuelSdk\ET_Client;
use FuelSdk\ET_ContentArea;
try {
$myclient = new ET_Client();
// Retrieve All ContentArea with GetMoreResults
print "Retrieve All ContentArea with GetMoreResults \n";
$getContent = new ET_ContentArea();
$getContent->authStub = $myclient;
$getContent->props = array("RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key");
$getResponse = $getContent->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 ContentArea with GetMoreResults \n";
$getResponse = $getContent->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";
}
$NameOfTestContentArea = "PHPSDKContentArea";
// Create ContentArea
print "Create ContentArea \n";
$postContent = new ET_ContentArea();
$postContent->authStub = $myclient;
$postContent->props = array("CustomerKey" => $NameOfTestContentArea, "Name"=>$NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here</b>");
$postResult = $postContent->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 ContentArea
print "Retrieve newly created ContentArea \n";
$getContent = new ET_ContentArea();
$getContent->authStub = $myclient;
$getContent->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestContentArea);
$getContent->props = array("RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key");
$getResponse = $getContent->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 ContentArea
print "Updates ContentArea \n";
$subPatch = new ET_ContentArea();
$subPatch->authStub = $myclient;
$subPatch->props = array("CustomerKey" => $NameOfTestContentArea, "Name"=>$NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>");
$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 ContentArea
print "Retrieve Updated ContentArea \n";
$getContent = new ET_ContentArea();
$getContent->authStub = $myclient;
$getContent->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestContentArea);
$getContent->props = array("RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key");
$getResponse = $getContent->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 ContentArea
print "Delete ContentArea \n";
$deleteContent = new ET_ContentArea();
$deleteContent->authStub = $myclient;
$deleteContent->props = array("CustomerKey" => $NameOfTestContentArea);
$deleteResponse = $deleteContent->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 ContentArea to confirm deletion
print "Retrieve ContentArea to confirm deletion \n";
$getContent = new ET_ContentArea();
$getContent->authStub = $myclient;
$getContent->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestContentArea);
$getContent->props = array("RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key");
$getResponse = $getContent->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";
}
?>