Guzzle log plugin to inject the HMAC into the headers

dev-master 2014-06-20 22:03 UTC

This package is not auto-updated.

Last update: 2023-12-09 10:12:11 UTC


This plugin will inject the HMAC hash/data/time values directly into the headers of the Guzzle request.

Mardy-Git Hmac:



To install this use composer by adding

"require": {
    "guzzle/plugin-mardy-hmac": "dev-master"

to your composer.json file

Usage Example

use Mardy\Hmac\Manager;
use Mardy\Hmac\Adapters\Hash;
use Mardy\HmacPlugins\HmacGuzzlePlugin;
use Guzzle\Http\Client;

$manager = new Manager(new Hash);
$client = new Client('');

              ->data('test') //string containing either a URI or other related data string
              ->time(1396901689) //timestamp for now or whatever other time you want to base the hmac on
              ->key('1234'); //a secure key string that is kept private in the database or config files

$client->addSubscriber(new HmacGuzzlePlugin($this->manager));

$request = $client->get();

//to check what data has been placed in the header it can be retrieved with by using the following code
echo $request->getHeader('Mardy-Hmac-Hash');
echo $request->getHeader('Mardy-Hmac-Time');
echo $request->getHeader('Mardy-Hmac-Data');