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