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 categories #
|
|
|
11 |
// GET /categories #
|
|
|
12 |
|
|
|
13 |
$query_params = json_decode('{"category": "test_string", "limit": 1, "offset": 1}');
|
|
|
14 |
$response = $sg->client->categories()->get(null, $query_params);
|
|
|
15 |
echo $response->statusCode();
|
|
|
16 |
echo $response->body();
|
|
|
17 |
echo $response->headers();
|
|
|
18 |
|
|
|
19 |
////////////////////////////////////////////////////
|
|
|
20 |
// Retrieve Email Statistics for Categories #
|
|
|
21 |
// GET /categories/stats #
|
|
|
22 |
|
|
|
23 |
$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "categories": "test_string"}');
|
|
|
24 |
$response = $sg->client->categories()->stats()->get(null, $query_params);
|
|
|
25 |
echo $response->statusCode();
|
|
|
26 |
echo $response->body();
|
|
|
27 |
echo $response->headers();
|
|
|
28 |
|
|
|
29 |
////////////////////////////////////////////////////
|
|
|
30 |
// Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] #
|
|
|
31 |
// GET /categories/stats/sums #
|
|
|
32 |
|
|
|
33 |
$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}');
|
|
|
34 |
$response = $sg->client->categories()->stats()->sums()->get(null, $query_params);
|
|
|
35 |
echo $response->statusCode();
|
|
|
36 |
echo $response->body();
|
|
|
37 |
echo $response->headers();
|