Skip to content

mobomo/guzzle-azure-hmac-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request;
use Mobomo\AzureHmacAuth\AzureHMACMiddleware;

$azureHMACMiddleware = new AzureHMACMiddleware('<secret key>');

$handlerStack = HandlerStack::create();
$handlerStack->push($azureHMACMiddleware, 'hmac-auth');

$resourceEndpoint = "https://<hostname>.communication.azure.com";
$requestPath = "/emails:send?api-version=2023-03-31";
$requestUri = "{$resourceEndpoint}{$requestPath}";

$serializedBody = "<json>";

$client = new Client([
    'handler' => $handlerStack,
]);
$requestMessage = new Request(
    'POST',
    $requestUri,
    array(
        'Content-Type' => 'application/json',
    ),
    $serializedBody
);

$response = $client->send($requestMessage);