PHP code example of sendgrid / php-http-client
1. Go to this page and download the library: Download sendgrid/php-http-client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sendgrid / php-http-client example snippets
e_once __DIR__ . '/lib/php-http-client/lib/Response.php';
nt = new SendGrid\Client();
// include __DIR__ . '/loader.php';
uthHeaders = [
'Authorization: Bearer ' . $apiKey
];
$client = new SendGrid\Client('https://api.sendgrid.com', $authHeaders);
$param = 'foo';
$response = $client->your()->api()->_($param)->call()->get();
var_dump(
$response->statusCode(),
$response->headers(),
$response->body()
);
// include __DIR__ . '/loader.php';
uthHeaders = [
'Authorization: Bearer ' . $apiKey
];
$client = new SendGrid\Client('https://api.sendgrid.com', $authHeaders);
$queryParams = [
'hello' => 0, 'world' => 1
];
$requestHeaders = [
'X-Test' => 'test'
];
$data = [
'some' => 1, 'awesome' => 2, 'data' => 3
];
$param = 'bar';
$response = $client->your()->api()->_($param)->call()->post($data, $queryParams, $requestHeaders);
var_dump(
$response->statusCode(),
$response->headers(),
$response->body()
);
json
{
"dgrid/php-http-client": "^4.1.1"
}
}