A PHP SDK for Sending-Network.
composer require sending-network/sdn-php-sdk
Provide server node url, wallet address, private key and developer key in file bot.creds.json:
{
"nodeUrl": "https://example.com",
"walletAddress": "<WALLET_ADDRESS>",
"privateKey": "<PRIVATE_KEY>",
"developerKey": "<DEVELOPER_KEY>"
}
require('vendor/autoload.php');
use SdnSdk\SDNClient;
$json_data = file_get_contents("bot.creds.json");
$config = json_decode($json_data,true);
$client = new SDNClient($config['nodeUrl']);
// login
$token = $client->login($config['walletAddress'], $config['privateKey'], $config['developerKey']);
// add listener for events
$client->addListener(function ($event) {
// process room event here
print_r($event);
}, "m.room.message");
// start listen
$client->listenForever();
// create new room
$client->createRoom("room name");
// invite user
$client->getRoom($roomId)->inviteUser($userId);
// send message
$client->getRoom($roomId)->sendText("hello");
See more use cases in examples
directory.