What is Nostr?
yoniji / Yoniji
npub1cn8…ue2t
2023-02-27 13:50:51

yoniji on Nostr: awesome works: PHP... thx for the dude who wrote the little php script: ...

awesome works: PHP... thx for the dude who wrote the little php script: error_reporting(E_ALL);
ini_set('display_errors', '1');

require_once './vendor/autoload.php';

use WebSocket\Client;
use WebSocket\ConnectionException;
use swentel\nostr\Sign;

$public_key = "0eef5af5e248a8b1f6e77a817166184556d5cff1351b7013e60acd1d6d533431";
$private_key = "3de0d7c4e82874fdc98c1e32a173a77fe9b50639c96bcf53621c79c7279f52b6";
$relay = "wss://ch1.duno.com";

$event = ['pubkey' => $public_key, 'created_at' => time(), 'kind' => 1, 'tags' => [], 'content' => "test"];

$signer = new Sign();
$event = $signer->sign($event, $private_key);

$message = '';
if (!empty($event['id'])) {
$message = '["EVENT", ' . json_encode($event) . ']';
}

if (!empty($message)) {
$client = new Client($relay);
try {

// TODO verify the response, we're not sure if it was actually ok.
$client->send($message);

echo 'sending';
}
catch (\Exception $e) {
echo 'error post';
}
}
Author Public Key
npub1cn8uwpduwx09876dtqh3mwvch6p54t6drzxzz3dv8hlxgug0nkkquyue2t