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-sentevent.php
executable file
·77 lines (63 loc) · 3.1 KB
/
sample-sentevent.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_SentEvent;
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 = "2013-01-15T13:00:00.000";
// Retrieve Filtered SentEvent with GetMoreResults
print "Retrieve Filtered SentEvent with GetMoreResults \n";
$getSentEvent = new ET_SentEvent();
$getSentEvent->authStub = $myclient;
$getSentEvent->props = array("SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID");
$getSentEvent->filter = array('Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => $retrieveDate);
$getSentEvent->getSinceLastBatch = false;
$getResponse = $getSentEvent->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 SentEvent with GetMoreResults \n";
$getResponse = $getSentEvent->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 SentEvent with GetMoreResults
print "Retrieve All SentEvent with GetMoreResults \n";
$getSentEvent = new ET_SentEvent();
$getSentEvent->authStub = $myclient;
$getSentEvent->props = array("SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID");
$getResponse = $getSentEvent->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 SentEvent with GetMoreResults \n";
$getResponse = $getSentEvent->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";
}
?>