Closed eko2one closed 1 year ago
Totally fine with using textalk/websocket - that's currently a dependency in the Drupal module, but would love to get rid of it.
Fwiw, this is the code in the module - the check on the response should be cleaned up totally though :)
$client = new Client($relay);
$client->send($message);
$response = json_decode($client->receive());
$success = TRUE;
$failure = '';
if (!empty($response[3])) {
$success = FALSE;
$failure = $response[3];
}
Aight! I am on it ;)
The response from a release, once decoded, has 4 possible values, e.g, for success:
[0] => OK [1] => abf48fb42fcde52fd25bb485e084b52d600618fd56ef74ab46ee5b88dd1dcb1a [2] => 1 [3] =>
In case of failures, the error message will be in the third key, and 2 will be empty then.
Added publish
method in https://github.com/swentel/nostr-php/pull/13
Renamed the issue title, otherwise we could just go on forever in this one :)
In accordance with nostr-tools https://github.com/nbd-wtf/nostr-tools#interacting-with-a-relay We could implement methods to interact with a relay. For websocket connection it could be used: https://github.com/Textalk/websocket-php