PHP code example of nostriphant / client
1. Go to this page and download the library: Download nostriphant/client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nostriphant / client example snippets
use nostriphant\Client\Client;
$client = Client::connectToUrl("wss://nos.lol", "wss://relay.damus.io");
$client(function(callable $send, callable $subscribe) {
$subscription = $subscribe(ids: ['hex_event_id']);
$subscription(function(?\nostriphant\NIP01\Event $event, callable $close, callable $stop) {
if (is_null($event)) {
// EOSE
} else {
// EVENT RECEIVED
}
});
$event = new \nostriphant\NIP01\Event(...);
$send($event, function(bool $accepted, string $reason, callable $stop) {
// handle response
});
});