You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 4, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,19 +24,21 @@ use ParagonIE\Sapient\CryptographyKeys\SigningPublicKey;
24
24
use ParagonIE\Sapient\CryptographyKeys\SigningSecretKey;
25
25
26
26
$api = new Api(
27
-
new Client(), // Client must implement Http\Client\HttpClient
27
+
new Client(), // Client must implement Http\Client\HttpAsyncClient
28
28
new RequestFactory(), // RequestFactory must implement Interop\Http\Factory\RequestFactoryInterface
29
29
'https://chronicle.uri',
30
30
new SigningPublicKey(Base64UrlSafe::decode('chronicle public key')) // optional, omit if you don't care about validating API responses
31
31
);
32
-
$api->lastHash();
32
+
var_dump($api->lastHash()->wait());
33
33
34
34
// you must authenticate first before you can publish a message
35
35
$api->authenticate(
36
36
new SigningSecretKey(Base64UrlSafe::decode('your secret key')),
37
37
'your client id'
38
38
);
39
-
$api->publish('hello world');
39
+
var_dump($api->publish('hello world')->wait());
40
40
```
41
41
42
42
For implementations of client and request factory, you can use for example [Guzzle 6 HTTP Adapter](https://github.com/php-http/guzzle6-adapter) and [HTTP Factory for Guzzle](https://github.com/http-interop/http-factory-guzzle) respectively.
43
+
44
+
All endpoints return `Http\Promise\Promise`, so you can either just `->wait()` for the response, or handle it asynchronously with `->then()`. Responses are just plain arrays, look up the structure in the Chronicle's documentation.
0 commit comments