Foros del Web » Programando para Internet » PHP »

Hay alquien que haya trabajado ...

Estas en el tema de Hay alquien que haya trabajado ... en el foro de PHP en Foros del Web. Existe alguien que haya trabajado con la clase class.jabber.php. Tengo el siguiente código: Código PHP: <?  ob_start ();  require( "functions.php" );   nocache ();   if((isset( ...
  #1 (permalink)  
Antiguo 20/04/2004, 21:26
Avatar de Reynier  
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 3 meses
Puntos: 1
Hay alquien que haya trabajado ...

Existe alguien que haya trabajado con la clase class.jabber.php. Tengo el siguiente código:
Código PHP:
<?
 ob_start
();
 require(
"functions.php");
 
nocache();
  if((isset(
$action))&&($action=="singin")){
   include(
'includes/class.jabber.php');
   
$jab = new Jabber();
   
$jab->username $_POST['login'];
   
$jab->password $_POST['password'];
   
$jab->resource "ClassJabberPHP";
   
$jab->enable_logging TRUE;
   
$jab->log_filename 'logs/logjab.log';
   
$jab->Connect() or die("No me he podido conectar la Servidor de Jabber: ".$_POST['server']."");
   
$jab->SendPresence("available""online");
   if(
$jab->connected){
    echo 
"sdfjsdfjksdhfjksdhfjkasdghfgasdjgfasdgf";
   }else{
    echo 
"efkjsfjkhfdgjkhjdg";
   }
   
$jab->SendMessage("[email protected]""chat"NULL, array("body" => "This is the message text"));
  }
 
ob_end_flush();
?>
se me conecta porque me imprime
Cita:
sdfjsdfjksdhfjksdhfjkasdghfgasdjgfasdgf
pero no me envia el mensaje a [email protected]
Alguien tiene idea de que pasa?

Salu2
__________________
Ing. Reynier Pérez Mira
  #2 (permalink)  
Antiguo 20/04/2004, 22:32
 
Fecha de Ingreso: marzo-2004
Ubicación: $_SERVER['DOCUMENT_ROOT'] :-)
Mensajes: 100
Antigüedad: 20 años
Puntos: 0
Para saber que pasa habría que ver la definición del método sendmessage
__________________
-- girls.code.better --
  #3 (permalink)  
Antiguo 21/04/2004, 07:13
Avatar de Reynier  
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 3 meses
Puntos: 1
Mira ...

Mira aquí tienen la implementación de SendMessage
Código PHP:
function SendMessage($to$type "normal"$id NULL$content NULL$payload NULL)
    {
        if (
$to && is_array($content))
        {
            if (!
$id)
            {
                
$id $type "_" time();
            }

            
$content $this->_array_htmlspecialchars($content);

            
$xml "<message to='$to' type='$type' id='$id'>\n";

            if (
$content['subject'])
            {
                
$xml .= "<subject>" $content['subject'] . "</subject>\n";
            }

            if (
$content['thread'])
            {
                
$xml .= "<thread>" $content['thread'] . "</thread>\n";
            }

            
$xml .= "<body>" $content['body'] . "</body>\n";
            
$xml .= $payload;
            
$xml .= "</message>\n";


            if (
$this->SendPacket($xml))
            {
                return 
TRUE;
            }
            else
            {
                
$this->AddToLog("ERROR: SendMessage() #1");
                return 
FALSE;
            }
        }
        else
        {
            
$this->AddToLog("ERROR: SendMessage() #2");
            return 
FALSE;
        }
    } 
Salu2
__________________
Ing. Reynier Pérez Mira
  #4 (permalink)  
Antiguo 21/04/2004, 07:23
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 9 meses
Puntos: 16
Hola,

Mirando la documentacion de la clase, veo que en los ejemplos siempre usa SendAuth(9 despues del Connect(). Y en http://phpjabber.g-blog.net/SendAuth
Cita:
After opening the Jabber stream via Connect(), the client needs to authenticate
Asi que creo que se te ha olvidado usar esa funcion. No lo se seguro porque no he usado nunca la clase (ni jabber, para el caso).

Suerte.

PD: La clase guarda los errores en un fichero de log, suele ser recomendable mirarlo para saber exactamente donde falla.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
  #5 (permalink)  
Antiguo 21/04/2004, 08:26
Avatar de Reynier  
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 3 meses
Puntos: 1
Nada

ahora lo he puesto así y nada
Código PHP:
<?
 ob_start
();
 require(
"functions.php");
 
nocache();
  if((isset(
$action))&&($action=="singin")){
   include(
'includes/class.jabber.php');
   
$jab = new Jabber();
   
$jab->username $_POST['login'];
   
$jab->password $_POST['password'];
   
$jab->resource "ClassJabberPHP";
   
$jab->enable_logging TRUE;
   
$jab->log_filename 'logs/logjab.log';
   
$jab->Connect() or die("No me he podido conectar la Servidor de Jabber: ".$_POST['server']."");
   
$jab->SendAuth();
   
$jab->SendPresence("available""online");
   if(
$jab->connected){
    echo 
"sdfjsdfjksdhfjksdhfjkasdghfgasdjgfasdgf";
   }else{
    echo 
"efkjsfjkhfdgjkhjdg";
   }
   
$jab->SendMessage("[email protected]""chat"NULL, array("body" => "This is the message text"));
  }
 
ob_end_flush();
?>
el fichero de logs contiene esto:
Cita:
SEND: <?xml version='1.0' encoding='UTF-8' ?>

SEND: <stream:stream to='jabber.uci.cu' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>

RECV: <?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' id='408684AB' xmlns='jabber:client' from='jabber.uci.cu'>

SEND: <iq type='get' id='auth_606ee82ed4d824918740175e7b4c943c'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
</query>
</iq>

RECV: <iq type='result' id='auth_606ee82ed4d824918740175e7b4c943c'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
<password/><digest/><sequence>297</sequence><token>3FC53725</token><resource/></query>
</iq>

ATTENTION: SendAuth() - mhash() is not available; screw 0k and digest method, we need to go with plaintext auth

SEND: <iq type='set' id='auth_606ee82ed4d824918740175e7b4c943c'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
<password></password>
<resource>ClassJabberPHP</resource>
</query>
</iq>

RECV: <iq type='error' id='auth_606ee82ed4d824918740175e7b4c943c'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
<password/>
<resource>ClassJabberPHP</resource>
</query>
<error code='401'>Unauthorized</error></iq>

ERROR: _sendauth_plaintext() #1
__________________
Ing. Reynier Pérez Mira
  #6 (permalink)  
Antiguo 21/04/2004, 09:06
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 9 meses
Puntos: 16
Fijate en el log, lo que pasa es que ha fallado la autentificacion. Por el mensaje parece que no le has pasado un password, verifica el nombre del campo del formulario. Para hacer la prueba mete directamente en el codigo el user y el pass en lugar de usar el formulario. Una vez que te funcione asi, solo es pasar los datos del formulario.

Saludos.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
  #7 (permalink)  
Antiguo 21/04/2004, 09:37
Avatar de Reynier  
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 3 meses
Puntos: 1
Josemi ...

Ahora lo he puesto como me dijistes:
Código PHP:
 <?
 ob_start
();
 require(
"functions.php");
 
nocache();
  if((isset(
$action))&&($action=="singin")){
   include(
'includes/class.jabber.php');
   
$jab = new Jabber();
   
$jab->username "rperezm";
   
$jab->password "andresalejandro";
   
$jab->resource "ClassJabberPHP";
   
$jab->enable_logging TRUE;
   
$jab->log_filename 'logs/logjabb.log';
   
$jab->Connect() or die("No me he podido conectar la Servidor de Jabber: ".$_POST['server']."");
   
$jab->SendAuth() or die("No me he podido autentificar");
   
$jab->SendPresence("available""online");
   if(
$jab->connected){
    echo 
"Conectado";
   }else{
    echo 
"No conectado";
   }
   
$jab->SendMessage("[email protected]""chat"NULL, array("body" => "Esto está OK"));
  }
 
ob_end_flush();
?>
y el error que me da es este
Cita:
SEND: <?xml version='1.0' encoding='UTF-8' ?>

SEND: <stream:stream to='jabber.uci.cu' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>

RECV: <?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' id='408693B6' xmlns='jabber:client' from='jabber.uci.cu'>

SEND: <iq type='get' id='auth_8bbe1e33582394de24ff1124693503bc'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
</query>
</iq>

RECV: <iq type='result' id='auth_8bbe1e33582394de24ff1124693503bc'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
<password/><digest/><sequence>297</sequence><token>3FC53725</token><resource/></query>
</iq>

ATTENTION: SendAuth() - mhash() is not available; screw 0k and digest method, we need to go with plaintext auth

SEND: <iq type='set' id='auth_8bbe1e33582394de24ff1124693503bc'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
<password>andresalejandro</password>
<resource>ClassJabberPHP</resource>
</query>
</iq>

RECV: <iq type='result' id='auth_8bbe1e33582394de24ff1124693503bc'/>

SEND: <presence to='online' type='available' />

SEND: <message to='[email protected]' type='chat' id='chat_1074713044'>
<body>Esto está OK</body>
</message>
este es el fichero de log del jabber normal es decir el .exe
Cita:
SEND: <?xml version="1.0" encoding="UTF-8"?><stream:stream to="jabber.uci.cu" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
RECV: <?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' id='403A779A' xmlns='jabber:client' from='jabber.uci.cu'>
SEND: <iq type="set" id="JAJSAuth"><query xmlns="jabber:iq:auth"><username>yromero</username><digest>0eb3dbef359006bc3e08dcbba9c456e2b dd67810</digest><resource>Just another jabber client</resource></query></iq>
RECV: <iq type='result' id='JAJSAuth'/>
SEND: <iq type="set" id="jajc_offline_filter"><query xmlns="jabber:iq:filter"/></iq>
SEND: <iq type="get" to="jabber.uci.cu" id="jajl1"><query xmlns="jabber:iq:browse"/></iq>
SEND: <iq type="get" id="JAJSRoster"><query xmlns="jabber:iq:roster"/></iq>
RECV: <iq type='result' id='jajc_offline_filter' from='[email protected]/Just another jabber client' to='[email protected]/Just another jabber client'/>
RECV: <iq type='result' to='[email protected]/Just another jabber client' id='jajl1' from='jabber.uci.cu'><service xmlns='jabber:iq:browse' type='jabber' jid='jabber.uci.cu' name='Jabber Server'>



<service type='jud' jid='jud.jabber.uci.cu' name='Jabber User Directory'>
<ns>jabber:iq:search</ns>
<ns>jabber:iq:register</ns>
</service>
y las diferencias que veo entre el mio y el otro son estas:
Jabber.exe
SEND: <iq type="set" id="JAJSAuth"><query xmlns="jabber:iq:auth"><username>yromero</username><digest>0eb3dbef359006bc3e08dcbba9c456e2bdd6781 0</digest>< resource>Just another jabber client</resource></query></iq>

jabber.php

SEND: <iq type='set' id='auth_8bbe1e33582394de24ff1124693503bc'>
<query xmlns='jabber:iq:auth'>
<username>rperezm</username>
<password>andresalejandro</password>
<resource>ClassJabberPHP</resource>
</query>
</iq>

RECV: <iq type='result' id='auth_8bbe1e33582394de24ff1124693503bc'/>


ya he bajado la librería mhash pero la tengo que compilar para windows y no se como hacerlo. Si alguien ya tiene la dll, please que me ayude. La necesito de verás.

Salu2
__________________
Ing. Reynier Pérez Mira

Última edición por Reynier; 21/04/2004 a las 09:41
  #8 (permalink)  
Antiguo 21/04/2004, 09:45
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 9 meses
Puntos: 16
¿Te ha mandado el mensaje? Por lo que parece si. Al menos es lo que pone el log.

Por lo de mhash(), por los mensajes del log parece que si no la tienes lo envia por texto plano, siendo mas inseguro. Pero parece que deberia funcionar.

Como no se que diablos es jabber (¿como messenger o como IRC?), pues no se cual es el funcionamiento normal de intercambio de mensajes entre servidor y cliente.

Saludos.

PD: Por cierto, no veo que en ningun momento desconectes. Puede que sea necesario. Te aconsejaria que empezases copiando los ejemplos de su pagina, y luego modificandolos para lo que quieras hacer.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
  #9 (permalink)  
Antiguo 21/04/2004, 09:53
Avatar de Reynier  
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 3 meses
Puntos: 1
Bueno

Josemi, me lo envío solo la primera vez que ejecute el script por lo del mhash creo que sería un poco más seguro enviarla encriptada que plana. Lo otro es que he probado los ejemplos y tampoco me funcionan. Ah !! Jabber es más o menos un messenger .En mi escuela lo usamos internamente pues no disponemos de Hotmail ni nada por el estilo. Más informacion: http://www.jabber.org

Salu2
__________________
Ing. Reynier Pérez Mira
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:58.