OpenFire and PHP

Hello

I want to know how can I manage openfire with PHP? I know The REST API Plugin provides the ability to manage Openfire by sending an REST/HTTP request to the server. but I limit to these data types

  • User
  • RosterItem
  • Chatroom
  • System Property
  • Session
  • Sessions count
    For example , I cannot get user status (Online/Offline) , or user’s last login/logout time

last activity time is very important for me and I cannot access this property

How can I get last logout time of user@myhost.ltd ???

Use an external database or openfire ? it is possible to know when someone turns off or if it is connected by PHP but this requires teres an external database to go get the information.

Actually, it seem that you have a lot of questions. Let’s start by getting your user status.

This can be done in two ways, the first one is to make sure this user is in the roster list and there are many methods to do this.

Second possibility, is to use Presence Plugin, you get get any user status by a simple HTTP request

1 Like

My friend…

Last log off… PHP + MySQL

$id = “Username name get last log off”;

$host = “127.0.0.1”;

$username = “username”;

$password = “pass”;

$_SESSION[connection] = mysql_connect($host, $username, $password) or die(“Error database”);

$bd = “jabberBD”;

$query = “SELECT * FROM $bd.userstatus ORDER by lastLogoffDate”;

$resultr = mysql_query($query);

if (!$resultr) {

echo 'Error on consult: ’ . mysql_error();

exit;

}else {

while ( $rowd = mysql_fetch_assoc($resultr)) {

if( $rowd[‘username’] == $id ){

$timestamp = $rowd[‘lastLogoffDate’];

$findme = ’ ';

$pos = strpos($timestamp, $findme);

$result = substr($timestamp,$pos,+12);

$datax = date(‘Y-m-d H:i:s’, $result);

$dt = DateTime::CreateFromFormat(“Y-m-d H:i:s”, $datax);

echo $dt;

}

}

}

friend so you can see the last time the person called … I first for me I see it is on or off , then you off is that I will get the time. but so you can see how it is.