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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<?php // If you are using Composer require 'vendor/autoload.php';
$apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey);
//////////////////////////////////////////////////// // Create a Sender Identity # // POST /senders #
$request_body = json_decode('{ "address": "123 Elm St.", "address_2": "Apt. 456", "city": "Denver", "country": "United States", "from": { "email": "from@example.com", "name": "Example INC" }, "nickname": "My Sender ID", "reply_to": { "email": "replyto@example.com", "name": "Example INC" }, "state": "Colorado", "zip": "80202" }'); $response = $sg->client->senders()->post($request_body); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Get all Sender Identities # // GET /senders #
$response = $sg->client->senders()->get(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Update a Sender Identity # // PATCH /senders/{sender_id} #
$request_body = json_decode('{ "address": "123 Elm St.", "address_2": "Apt. 456", "city": "Denver", "country": "United States", "from": { "email": "from@example.com", "name": "Example INC" }, "nickname": "My Sender ID", "reply_to": { "email": "replyto@example.com", "name": "Example INC" }, "state": "Colorado", "zip": "80202" }'); $sender_id = "test_url_param"; $response = $sg->client->senders()->_($sender_id)->patch($request_body); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // View a Sender Identity # // GET /senders/{sender_id} #
$sender_id = "test_url_param"; $response = $sg->client->senders()->_($sender_id)->get(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Delete a Sender Identity # // DELETE /senders/{sender_id} #
$sender_id = "test_url_param"; $response = $sg->client->senders()->_($sender_id)->delete(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
//////////////////////////////////////////////////// // Resend Sender Identity Verification # // POST /senders/{sender_id}/resend_verification #
$sender_id = "test_url_param"; $response = $sg->client->senders()->_($sender_id)->resend_verification()->post(); echo $response->statusCode(); echo $response->body(); print_r($response->headers());
|