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';
}
}
Published at
2023-02-27 13:50:51Event JSON
{
"id": "3e1d4539a47d102b174a7e711614c735581cad657855e28ce067754917332c5b",
"pubkey": "c4cfc705bc719e53fb4d582f1db998be834aaf4d188c2145ac3dfe64710f9dac",
"created_at": 1677505851,
"kind": 1,
"tags": [],
"content": "awesome works: PHP... thx for the dude who wrote the little php script: error_reporting(E_ALL);\nini_set('display_errors', '1');\n\nrequire_once './vendor/autoload.php';\n\nuse WebSocket\\Client;\nuse WebSocket\\ConnectionException;\nuse swentel\\nostr\\Sign;\n\n$public_key = \"0eef5af5e248a8b1f6e77a817166184556d5cff1351b7013e60acd1d6d533431\";\n$private_key = \"3de0d7c4e82874fdc98c1e32a173a77fe9b50639c96bcf53621c79c7279f52b6\";\n$relay = \"wss://ch1.duno.com\";\n\n$event = ['pubkey' =\u003e $public_key, 'created_at' =\u003e time(), 'kind' =\u003e 1, 'tags' =\u003e [], 'content' =\u003e \"test\"];\n\n$signer = new Sign();\n$event = $signer-\u003esign($event, $private_key);\n\n$message = '';\nif (!empty($event['id'])) {\n $message = '[\"EVENT\", ' . json_encode($event) . ']';\n}\n\nif (!empty($message)) {\n $client = new Client($relay);\n try {\n\n\t// TODO verify the response, we're not sure if it was actually ok.\n\t$client-\u003esend($message);\n\n\techo 'sending';\n }\n catch (\\Exception $e) {\n\t\techo 'error post';\n }\n}\n",
"sig": "08b1dbeb539af8e91a051ebb0605ed4630ccb51ed78f2c1d75dd27b89203fd99bd7be654e1ef47d4a37b5ff302bc114687ccae9044e0c1f00c8f962541a6a487"
}