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
|
<?php // If you are using Composer require 'vendor/autoload.php';
$apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey);
//////////////////////////////////////////////////// // Create a new Alert # // POST /alerts #
$request_body = json_decode('{ "email_to": "example@example.com", "frequency": "daily", "type": "stats_notification" }'); $response = $sg->client->alerts()->post($request_body); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Retrieve all alerts # // GET /alerts #
$response = $sg->client->alerts()->get(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Update an alert # // PATCH /alerts/{alert_id} #
$request_body = json_decode('{ "email_to": "example@example.com" }'); $alert_id = "test_url_param"; $response = $sg->client->alerts()->_($alert_id)->patch($request_body); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Retrieve a specific alert # // GET /alerts/{alert_id} #
$alert_id = "test_url_param"; $response = $sg->client->alerts()->_($alert_id)->get(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Delete an alert # // DELETE /alerts/{alert_id} #
$alert_id = "test_url_param"; $response = $sg->client->alerts()->_($alert_id)->delete(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
|