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-email.php
executable file
·134 lines (120 loc) · 6.37 KB
/
sample-email.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_Email;
try {
$myclient = new ET_Client();
// Retrieve All Email with GetMoreResults
print "Retrieve All Email with GetMoreResults \n";
$getEmail = new ET_Email();
$getEmail->authStub = $myclient;
$getEmail->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey");
$getResponse = $getEmail->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 Email with GetMoreResults \n";
$getResponse = $getEmail->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";
}
$NameOfTestEmail = "PHPSDKEmail".uniqid();
// Create Email
print "Create Email \n";
$postEmail = new ET_Email();
$postEmail->authStub = $myclient;
$postEmail->props = array("CustomerKey" => $NameOfTestEmail, "Name"=>$NameOfTestEmail, "Subject"=>"Created with the SDK", "HTMLBody"=> "<b>Some HTML Goes here</b>", "EmailType" => "HTML", "IsHTMLPaste" => "true");
$postResult = $postEmail->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 Email
print "Retrieve newly created Email \n";
$getEmail = new ET_Email();
$getEmail->authStub = $myclient;
$getEmail->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestEmail);
$getEmail->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey");
$getResponse = $getEmail->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 Email
print "Updates Email \n";
$patchEmail = new ET_Email();
$patchEmail->authStub = $myclient;
$patchEmail->props = array("CustomerKey" => $NameOfTestEmail, "Name"=>$NameOfTestEmail, "Subject"=>"Created with the SDK!!! Now with more !!!!", "HTMLBody"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>");
$patchResult = $patchEmail->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 Email
print "Retrieve Updated Email \n";
$getEmail = new ET_Email();
$getEmail->authStub = $myclient;
$getEmail->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestEmail);
$getEmail->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey");
$getResponse = $getEmail->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 Email
print "Delete Email \n";
$deleteEmail = new ET_Email();
$deleteEmail->authStub = $myclient;
$deleteEmail->props = array("CustomerKey" => $NameOfTestEmail);
$deleteResponse = $deleteEmail->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 Email to confirm deletion
print "Retrieve Email to confirm deletion \n";
$getEmail = new ET_Email();
$getEmail->authStub = $myclient;
$getEmail->filter = array('Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => $NameOfTestEmail);
$getEmail->props = array("ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey");
$getResponse = $getEmail->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";
}
?>