Пример #1
0
 private function buildClient($offset)
 {
     $builder = ClientBuilder::create();
     if ($offset) {
         $builder = $builder->setLocaltimeOffset($offset);
     }
     return $builder->build();
 }
Пример #2
0
 private function buildClient()
 {
     $builder = ClientBuilder::create();
     return $builder->build();
 }
Пример #3
0
 /**
  * @test
  */
 public function shouldCreateBewit()
 {
     $client = ClientBuilder::create()->build();
     $tentTestVectorsCredentials = new Credentials('HX9QcbD-r3ItFEnRcAuOSg', 'sha256', 'exqbZWtykFZIh2D7cXi9dA');
     $this->assertEquals('ZXhxYlpXdHlrRlpJaDJEN2NYaTlkQVwxMzY4OTk2ODAwXE8wbWhwcmdvWHFGNDhEbHc1RldBV3ZWUUlwZ0dZc3FzWDc2dHBvNkt5cUk9XA', $client->createBewit($tentTestVectorsCredentials, 'https://example.com/posts', 0, array('timestamp' => 1368996800)));
 }
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Tornado\Component\HawkAuthentication\HawkAuthenticationSubscriber;
use Dflydev\Hawk\Client\ClientBuilder;
use Dflydev\Hawk\Credentials\Credentials;
use GuzzleHttp\Client;
$id = '12345';
$secret = 'asd';
$client = ClientBuilder::create()->build();
$credentials = new Credentials($secret, 'sha256', $id);
$hawkAuthenticationPlugin = new HawkAuthenticationSubscriber($client, $credentials);
$httpClient = new Client();
/** @var \GuzzleHttp\Message\Response $response */
$response = $httpClient->post('https://test.dev/app_dev.php/rest?a=b', ['json' => array('a' => 'b'), 'subscribers' => array($hawkAuthenticationPlugin)]);
echo (string) $response;