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-unsubevent.php
executable file
·77 lines (63 loc) · 3.08 KB
/
sample-unsubevent.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
<?php
include_once('tests/UnitBootstrap.php');
use FuelSdk\ET_Client;
use FuelSdk\ET_UnsubEvent;
try {
$myclient = new ET_Client();
// Modify the date below to reduce the number of results returned from the request
// Setting this too far in the past could result in a very large response size
$retrieveDate = "2017-01-15T13:00:00.000";
// Retrieve Filtered UnsubEvent with GetMoreResults
print "Retrieve Filtered UnsubEvent with GetMoreResults \n";
$getUnsubEvent = new ET_UnsubEvent();
$getUnsubEvent->authStub = $myclient;
$getUnsubEvent->props = array("SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey");
$getUnsubEvent->filter = array('Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => $retrieveDate);
$getUnsubEvent->getSinceLastBatch = false;
$getResponse = $getUnsubEvent->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 UnsubEvent with GetMoreResults \n";
$getResponse = $getUnsubEvent->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";
}
// The following request could potentially bring back large amounts of data if run against a production account
/*
// Retrieve All UnsubEvent with GetMoreResults
print "Retrieve All UnsubEvent with GetMoreResults \n";
$getUnsubEvent = new ET_UnsubEvent();
$getUnsubEvent->authStub = $myclient;
$getUnsubEvent->props = array("SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey");
$getResponse = $getUnsubEvent->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 UnsubEvent with GetMoreResults \n";
$getResponse = $getUnsubEvent->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";
}
*/
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>