Update package to support Guzzle 6 and stop supporting old versions.
This commit is contained in:
19
examples/basic_request_example.php
Normal file
19
examples/basic_request_example.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use HttpSignatures\Context;
|
||||
use HttpSignatures\GuzzleHttpSignatures;
|
||||
|
||||
require __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
$context = new Context([
|
||||
'keys' => ['examplekey' => 'secret-key-here'],
|
||||
'algorithm' => 'hmac-sha256',
|
||||
'headers' => ['(request-target)', 'date'],
|
||||
]);
|
||||
|
||||
$handlerStack = GuzzleHttpSignatures::defaultHandlerFromContext($context);
|
||||
$client = new Client(['handler' => $handlerStack]);
|
||||
|
||||
// The below will now send a signed request to: http://example.org/path?query=123
|
||||
$response = $client->get("http://www.example.com/path?query=123", ['headers' => ['date' => 'today']]);
|
||||
Reference in New Issue
Block a user