shuhaib864 / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

how to get contact list from gtalk #78

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
give how to call roster function to get contact list from gtalk

Original issue reported on code.google.com by r.nagend...@gmail.com on 10 Nov 2009 at 10:02

GoogleCodeExporter commented 8 years ago
Pra listar usuarios uso lo siguiente

<?php

include 'XMPPHP/XMPP.php';

function array_contactos($user,$pass){
    #Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports
    #If this doesn't work, are you running 64-bit PHP with < 5.2.6?
    $conn = new XMPPHP_XMPP('localhost', 5222, "$user","$pass", "xmpphp", 'okeyko.com', $printlog=false, $loglevel=XMPPHP_Log::LEVEL_INFO);
    $conn->autoSubscribe();

    $vcard_request = array();

    try {
        $conn->connect();
        while(!$conn->isDisconnected()) {
            $payloads = $conn->processUntil(array('end_stream', 'session_start','roster_received'));
            foreach($payloads as $event) {
                $pl = $event[1];
                switch($event[0]) {

                    case 'session_start':
                    //  print "Session Start\n";
                        $conn->getRoster();
                    //$conn->presence($status="Cheese!");
                    break;

                    case 'roster_received':
                    $array_contactos=$pl;
                    return $array_contactos;
                    /*
                    foreach($array_contactos as $user => $mostrar_nombre){
                        echo $user.'<br>';
                        echo $mostrar_nombre['name'];
                        echo '<hr>';
                    }*/

                    $conn->disconnect();
                    break;
                }
            }       
        }
    } catch(XMPPHP_Exception $e) {
        die($e->getMessage());
    }

}
$user_="dario";
$pass_=md5('adgjmp');

$results= array_contactos($user_,$pass_);

foreach($results as $users => $mostrar_name){
    echo $users.'<br>';
    echo $mostrar_name['name'];
    echo '<hr>';
}

Original comment by dariogabrielarias@gmail.com on 31 May 2011 at 11:10

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Do not use $pass_=md5('adgjmp');

instead use $pass_='adgjmp';

no need to encrypt of your password with MD5

Original comment by jay.vinf...@gmail.com on 4 Jul 2012 at 5:44

GoogleCodeExporter commented 8 years ago
Not works for me. I'm getting $payloads array as follows
Array ( [0] => Array ( [0] => session_start [1] => ) ) 

Not getting 'roster_received' event

Please advise. 

Thanks in advance!

Original comment by sachi...@tekdi.net on 3 Feb 2014 at 1:35