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 email statistics by client type. #
|
|
|
11 |
// GET /clients/stats #
|
|
|
12 |
|
|
|
13 |
$query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}');
|
|
|
14 |
$response = $sg->client->clients()->stats()->get(null, $query_params);
|
|
|
15 |
echo $response->statusCode();
|
|
|
16 |
echo $response->body();
|
|
|
17 |
echo $response->headers();
|
|
|
18 |
|
|
|
19 |
////////////////////////////////////////////////////
|
|
|
20 |
// Retrieve stats by a specific client type. #
|
|
|
21 |
// GET /clients/{client_type}/stats #
|
|
|
22 |
|
|
|
23 |
$query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}');
|
|
|
24 |
$client_type = "test_url_param";
|
|
|
25 |
$response = $sg->client->clients()->_($client_type)->stats()->get(null, $query_params);
|
|
|
26 |
echo $response->statusCode();
|
|
|
27 |
echo $response->body();
|
|
|
28 |
echo $response->headers();
|