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 141
/
sample-list.php
executable file
·139 lines (123 loc) · 5.83 KB
/
sample-list.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
<?php
include_once('tests/UnitBootstrap.php');
use FuelSdk\ET_Client;
use FuelSdk\ET_List;
try {
$NewListName = "PHPSDKList";
$myclient = new ET_Client();
// Retrieve All List with GetMoreResults
print "Retrieve All List with GetMoreResults \n";
$getList = new ET_List();
$getList->authStub = $myclient;
$getList->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID");
$getResponse = $getList->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 List with GetMoreResults \n";
$getResponse = $getList->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";
}
$NameOfTestList = "PHPSDKList";
// Create List
print "Create List \n";
$postContent = new ET_List();
$postContent->authStub = $myclient;
$postContent->props = array("ListName" => $NewListName, "Description" => "This list was created with the PHPSDK", "Type" => "Private");
$postResponse = $postContent->post();
print_r('Post Status: '.($postResponse->status ? 'true' : 'false')."\n");
print 'Code: '.$postResponse->code."\n";
print 'Message: '.$postResponse->message."\n";
print 'Results Length: '. count($postResponse->results)."\n";
print 'Results: '."\n";
print_r($postResponse->results);
print "\n---------------\n";
if ($postResponse->status){
$newListID = $postResponse->results[0]->NewID;
// Retrieve newly created List
print "Retrieve newly created List \n";
$getList = new ET_List();
$getList->authStub = $myclient;
$getList->filter = array('Property' => 'ID','SimpleOperator' => 'equals','Value' => $newListID);
$getList->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID");
$getResponse = $getList->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 the List
print "Update the List \n";
$patchList = new ET_List();
$patchList->authStub = $myclient;
$patchList->props = array("ID" => $newListID, "Description"=>"This list was created with the PHPSDK!!!");
$patchResult = $patchList->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 List
print "Retrieve Updated List \n";
$getList = new ET_List();
$getList->authStub = $myclient;
$getList->filter = array('Property' => 'ID','SimpleOperator' => 'equals','Value' => $newListID);
$getList->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID");
$getResponse = $getList->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 List
/* print "Delete List \n";
$deleteList = new ET_List();
$deleteList->authStub = $myclient;
$deleteList->props = array("ID" => $newListID);
$deleteResponse = $deleteList->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 List to confirm deletion
print "Retrieve List to confirm deletion \n";
$getList = new ET_List();
$getList->authStub = $myclient;
$getList->filter = array('Property' => 'ID','SimpleOperator' => 'equals','Value' => $newListID);
$getList->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID");
$getResponse = $getList->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";
}
?>