PHP code example of bubbladev / php-jabber-rpc

1. Go to this page and download the library: Download bubbladev/php-jabber-rpc 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/ */

    

bubbladev / php-jabber-rpc example snippets


    $rpc = new \GameNet\Jabber\RpcClient([
        'server' => 'http://127.0.0.1:4560',
        'host' => 'j.gamenet.ru',
        'debug' => false,
    ]);

    //Create 2 new users with name `Ivan` and `Petr` with password `someStrongPassword`
    $rpc->createUser('Ivan', 'someStrongPassword');
    $rpc->createUser('Petr', 'someStrongPassword');

    // Add each other in the contact list with group 'Friend'
    $rpc->addRosterItem('Ivan', 'Petr', 'Petr Ivanov', 'Friend');
    $rpc->addRosterItem('Petr', 'Ivan', 'Ivan Petrov', 'Friend');

    // Get contact list Ivan
    $contacts = $rpc->getRoster($username);
JSON
{
	"ladev/php-jabber-rpc": "*"
	}
}