get_roster() public method

public get_roster ( $cb = null )
コード例 #1
0
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$client = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'auth_type' => @$argv[3] ? $argv[3] : 'PLAIN', 'log_level' => JAXL_INFO));
//
// required XEP's
//
$client->require_xep(array('0199'));
//
// add necessary event callbacks here
//
$client->add_cb('on_auth_success', function () {
    global $client;
    _info("got on_auth_success cb, jid " . $client->full_jid->to_string());
    // fetch roster list
    $client->get_roster();
    // fetch vcard
    $client->get_vcard();
    // set status
    $client->set_status("available!", "dnd", 10);
});
// by default JAXL instance catches incoming roster list results and updates
// roster list is parsed/cached and an event 'on_roster_update' is emitted
$client->add_cb('on_roster_update', function () {
    //global $client;
    //print_r($client->roster);
});
$client->add_cb('on_auth_failure', function ($reason) {
    global $client;
    _info("got on_auth_failure cb with reason {$reason}");
    $client->send_end_stream();