103 |
- |
1 |
<?php
|
|
|
2 |
// If you are using Composer
|
|
|
3 |
require 'vendor/autoload.php';
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
$apiKey = getenv('SENDGRID_API_KEY');
|
|
|
7 |
$sg = new \SendGrid($apiKey);
|
|
|
8 |
|
|
|
9 |
////////////////////////////////////////////////////
|
|
|
10 |
// Retrieve all blocks #
|
|
|
11 |
// GET /suppression/blocks #
|
|
|
12 |
|
|
|
13 |
$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}');
|
|
|
14 |
$response = $sg->client->suppression()->blocks()->get(null, $query_params);
|
|
|
15 |
echo $response->statusCode();
|
|
|
16 |
echo $response->body();
|
|
|
17 |
echo $response->headers();
|
|
|
18 |
|
|
|
19 |
////////////////////////////////////////////////////
|
|
|
20 |
// Delete blocks #
|
|
|
21 |
// DELETE /suppression/blocks #
|
|
|
22 |
|
|
|
23 |
$request_body = json_decode('{
|
|
|
24 |
"delete_all": false,
|
|
|
25 |
"emails": [
|
|
|
26 |
"example1@example.com",
|
|
|
27 |
"example2@example.com"
|
|
|
28 |
]
|
|
|
29 |
}');
|
|
|
30 |
$response = $sg->client->suppression()->blocks()->delete($request_body);
|
|
|
31 |
echo $response->statusCode();
|
|
|
32 |
echo $response->body();
|
|
|
33 |
echo $response->headers();
|
|
|
34 |
|
|
|
35 |
////////////////////////////////////////////////////
|
|
|
36 |
// Retrieve a specific block #
|
|
|
37 |
// GET /suppression/blocks/{email} #
|
|
|
38 |
|
|
|
39 |
$email = "test_url_param";
|
|
|
40 |
$response = $sg->client->suppression()->blocks()->_($email)->get();
|
|
|
41 |
echo $response->statusCode();
|
|
|
42 |
echo $response->body();
|
|
|
43 |
echo $response->headers();
|
|
|
44 |
|
|
|
45 |
////////////////////////////////////////////////////
|
|
|
46 |
// Delete a specific block #
|
|
|
47 |
// DELETE /suppression/blocks/{email} #
|
|
|
48 |
|
|
|
49 |
$email = "test_url_param";
|
|
|
50 |
$response = $sg->client->suppression()->blocks()->_($email)->delete();
|
|
|
51 |
echo $response->statusCode();
|
|
|
52 |
echo $response->body();
|
|
|
53 |
echo $response->headers();
|
|
|
54 |
|
|
|
55 |
////////////////////////////////////////////////////
|
|
|
56 |
// Retrieve all bounces #
|
|
|
57 |
// GET /suppression/bounces #
|
|
|
58 |
|
|
|
59 |
$query_params = json_decode('{"start_time": 1, "end_time": 1}');
|
|
|
60 |
$response = $sg->client->suppression()->bounces()->get(null, $query_params);
|
|
|
61 |
echo $response->statusCode();
|
|
|
62 |
echo $response->body();
|
|
|
63 |
echo $response->headers();
|
|
|
64 |
|
|
|
65 |
////////////////////////////////////////////////////
|
|
|
66 |
// Delete bounces #
|
|
|
67 |
// DELETE /suppression/bounces #
|
|
|
68 |
|
|
|
69 |
$request_body = json_decode('{
|
|
|
70 |
"delete_all": true,
|
|
|
71 |
"emails": [
|
|
|
72 |
"example@example.com",
|
|
|
73 |
"example2@example.com"
|
|
|
74 |
]
|
|
|
75 |
}');
|
|
|
76 |
$response = $sg->client->suppression()->bounces()->delete($request_body);
|
|
|
77 |
echo $response->statusCode();
|
|
|
78 |
echo $response->body();
|
|
|
79 |
echo $response->headers();
|
|
|
80 |
|
|
|
81 |
////////////////////////////////////////////////////
|
|
|
82 |
// Retrieve a Bounce #
|
|
|
83 |
// GET /suppression/bounces/{email} #
|
|
|
84 |
|
|
|
85 |
$email = "test_url_param";
|
|
|
86 |
$response = $sg->client->suppression()->bounces()->_($email)->get();
|
|
|
87 |
echo $response->statusCode();
|
|
|
88 |
echo $response->body();
|
|
|
89 |
echo $response->headers();
|
|
|
90 |
|
|
|
91 |
////////////////////////////////////////////////////
|
|
|
92 |
// Delete a bounce #
|
|
|
93 |
// DELETE /suppression/bounces/{email} #
|
|
|
94 |
|
|
|
95 |
$query_params = json_decode('{"email_address": "example@example.com"}');
|
|
|
96 |
$email = "test_url_param";
|
|
|
97 |
$response = $sg->client->suppression()->bounces()->_($email)->delete(null, $query_params);
|
|
|
98 |
echo $response->statusCode();
|
|
|
99 |
echo $response->body();
|
|
|
100 |
echo $response->headers();
|
|
|
101 |
|
|
|
102 |
////////////////////////////////////////////////////
|
|
|
103 |
// Retrieve all invalid emails #
|
|
|
104 |
// GET /suppression/invalid_emails #
|
|
|
105 |
|
|
|
106 |
$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}');
|
|
|
107 |
$response = $sg->client->suppression()->invalid_emails()->get(null, $query_params);
|
|
|
108 |
echo $response->statusCode();
|
|
|
109 |
echo $response->body();
|
|
|
110 |
echo $response->headers();
|
|
|
111 |
|
|
|
112 |
////////////////////////////////////////////////////
|
|
|
113 |
// Delete invalid emails #
|
|
|
114 |
// DELETE /suppression/invalid_emails #
|
|
|
115 |
|
|
|
116 |
$request_body = json_decode('{
|
|
|
117 |
"delete_all": false,
|
|
|
118 |
"emails": [
|
|
|
119 |
"example1@example.com",
|
|
|
120 |
"example2@example.com"
|
|
|
121 |
]
|
|
|
122 |
}');
|
|
|
123 |
$response = $sg->client->suppression()->invalid_emails()->delete($request_body);
|
|
|
124 |
echo $response->statusCode();
|
|
|
125 |
echo $response->body();
|
|
|
126 |
echo $response->headers();
|
|
|
127 |
|
|
|
128 |
////////////////////////////////////////////////////
|
|
|
129 |
// Retrieve a specific invalid email #
|
|
|
130 |
// GET /suppression/invalid_emails/{email} #
|
|
|
131 |
|
|
|
132 |
$email = "test_url_param";
|
|
|
133 |
$response = $sg->client->suppression()->invalid_emails()->_($email)->get();
|
|
|
134 |
echo $response->statusCode();
|
|
|
135 |
echo $response->body();
|
|
|
136 |
echo $response->headers();
|
|
|
137 |
|
|
|
138 |
////////////////////////////////////////////////////
|
|
|
139 |
// Delete a specific invalid email #
|
|
|
140 |
// DELETE /suppression/invalid_emails/{email} #
|
|
|
141 |
|
|
|
142 |
$email = "test_url_param";
|
|
|
143 |
$response = $sg->client->suppression()->invalid_emails()->_($email)->delete();
|
|
|
144 |
echo $response->statusCode();
|
|
|
145 |
echo $response->body();
|
|
|
146 |
echo $response->headers();
|
|
|
147 |
|
|
|
148 |
////////////////////////////////////////////////////
|
|
|
149 |
// Retrieve a specific spam report #
|
|
|
150 |
// GET /suppression/spam_report/{email} #
|
|
|
151 |
|
|
|
152 |
$email = "test_url_param";
|
|
|
153 |
$response = $sg->client->suppression()->spam_report()->_($email)->get();
|
|
|
154 |
echo $response->statusCode();
|
|
|
155 |
echo $response->body();
|
|
|
156 |
echo $response->headers();
|
|
|
157 |
|
|
|
158 |
////////////////////////////////////////////////////
|
|
|
159 |
// Delete a specific spam report #
|
|
|
160 |
// DELETE /suppression/spam_report/{email} #
|
|
|
161 |
|
|
|
162 |
$email = "test_url_param";
|
|
|
163 |
$response = $sg->client->suppression()->spam_report()->_($email)->delete();
|
|
|
164 |
echo $response->statusCode();
|
|
|
165 |
echo $response->body();
|
|
|
166 |
echo $response->headers();
|
|
|
167 |
|
|
|
168 |
////////////////////////////////////////////////////
|
|
|
169 |
// Retrieve all spam reports #
|
|
|
170 |
// GET /suppression/spam_reports #
|
|
|
171 |
|
|
|
172 |
$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}');
|
|
|
173 |
$response = $sg->client->suppression()->spam_reports()->get(null, $query_params);
|
|
|
174 |
echo $response->statusCode();
|
|
|
175 |
echo $response->body();
|
|
|
176 |
echo $response->headers();
|
|
|
177 |
|
|
|
178 |
////////////////////////////////////////////////////
|
|
|
179 |
// Delete spam reports #
|
|
|
180 |
// DELETE /suppression/spam_reports #
|
|
|
181 |
|
|
|
182 |
$request_body = json_decode('{
|
|
|
183 |
"delete_all": false,
|
|
|
184 |
"emails": [
|
|
|
185 |
"example1@example.com",
|
|
|
186 |
"example2@example.com"
|
|
|
187 |
]
|
|
|
188 |
}');
|
|
|
189 |
$response = $sg->client->suppression()->spam_reports()->delete($request_body);
|
|
|
190 |
echo $response->statusCode();
|
|
|
191 |
echo $response->body();
|
|
|
192 |
echo $response->headers();
|
|
|
193 |
|
|
|
194 |
////////////////////////////////////////////////////
|
|
|
195 |
// Retrieve all global suppressions #
|
|
|
196 |
// GET /suppression/unsubscribes #
|
|
|
197 |
|
|
|
198 |
$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}');
|
|
|
199 |
$response = $sg->client->suppression()->unsubscribes()->get(null, $query_params);
|
|
|
200 |
echo $response->statusCode();
|
|
|
201 |
echo $response->body();
|
|
|
202 |
echo $response->headers();
|