PHP code example of gamenet / php-jabber-rpc

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

    

gamenet / 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
{
	"net/php-jabber-rpc": "*"
	}
}