http-signatures-guzzlehttp/README.md

42 lines
1.3 KiB
Markdown
Raw Normal View History

2014-10-06 09:07:16 +00:00
HTTP Signatures Guzzle 4
========================
2014-10-06 09:06:36 +00:00
Guzzle 4 support for 99designs http-signatures library
2014-08-27 07:45:39 +00:00
2014-10-06 08:21:26 +00:00
[![Build Status](https://travis-ci.org/99designs/http-signatures-guzzlehttp.svg)](https://travis-ci.org/99designs/http-signatures-guzzlehttp)
2014-10-27 23:15:56 +00:00
Adds [99designs/http-signatures][99signatures] support to Guzzle 4.
For Guzzle 3 see the [99designs/http-signatures-guzzle][99signatures-guzzle] repo.
2014-08-27 07:45:39 +00:00
2014-10-06 08:21:26 +00:00
Signing with Guzzle 4
---------------------
2014-08-27 07:45:39 +00:00
This library includes support for automatically signing Guzzle requests using an event subscriber.
```php
use HttpSignatures\Context;
2014-10-06 08:21:26 +00:00
use HttpSignatures\GuzzleHttp\RequestSubscriber;
2014-08-27 07:45:39 +00:00
$context = new Context(array(
'keys' => array('examplekey' => 'secret-key-here'),
'algorithm' => 'hmac-sha256',
'headers' => array('(request-target)', 'Date', 'Accept'),
));
2014-08-27 07:45:39 +00:00
$client = new \Guzzle\Http\Client('http://example.org');
2015-02-19 01:14:31 +00:00
$client->getEmitter()->attach(new RequestSubscriber($context));
2014-08-27 07:45:39 +00:00
// The below will now send a signed request to: http://example.org/path?query=123
$client->get('/path?query=123', array(
'Date' => 'Wed, 30 Jul 2014 16:40:19 -0700',
'Accept' => 'llamas',
2014-10-06 08:21:26 +00:00
));
2014-08-27 07:45:39 +00:00
```
## Contributing
Pull Requests are welcome.
2014-10-27 23:15:56 +00:00
[99signatures]: https://github.com/99designs/http-signatures-php
[99signatures-guzzle]: https://github.com/99designs/http-signatures-guzzle