Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
// Create a new Alert #
11
// POST /alerts #
12
 
13
$request_body = json_decode('{
14
  "email_to": "example@example.com",
15
  "frequency": "daily",
16
  "type": "stats_notification"
17
}');
18
$response = $sg->client->alerts()->post($request_body);
19
echo $response->statusCode();
20
echo $response->body();
21
echo $response->headers();
22
 
23
////////////////////////////////////////////////////
24
// Retrieve all alerts #
25
// GET /alerts #
26
 
27
$response = $sg->client->alerts()->get();
28
echo $response->statusCode();
29
echo $response->body();
30
echo $response->headers();
31
 
32
////////////////////////////////////////////////////
33
// Update an alert #
34
// PATCH /alerts/{alert_id} #
35
 
36
$request_body = json_decode('{
37
  "email_to": "example@example.com"
38
}');
39
$alert_id = "test_url_param";
40
$response = $sg->client->alerts()->_($alert_id)->patch($request_body);
41
echo $response->statusCode();
42
echo $response->body();
43
echo $response->headers();
44
 
45
////////////////////////////////////////////////////
46
// Retrieve a specific alert #
47
// GET /alerts/{alert_id} #
48
 
49
$alert_id = "test_url_param";
50
$response = $sg->client->alerts()->_($alert_id)->get();
51
echo $response->statusCode();
52
echo $response->body();
53
echo $response->headers();
54
 
55
////////////////////////////////////////////////////
56
// Delete an alert #
57
// DELETE /alerts/{alert_id} #
58
 
59
$alert_id = "test_url_param";
60
$response = $sg->client->alerts()->_($alert_id)->delete();
61
echo $response->statusCode();
62
echo $response->body();
63
echo $response->headers();