Display online users (merchants, affiliates) via API

The following script publishes the  merchants, affiliates being logged in.
// PapApi.class.php can be downloaded from the merchant panel at:
// Tools > Integration > API Integration > Download PAP API
// This include assumes the PapApi.class.php file is in the same directory as this particular script
include 'api/PapApi.class.php';

// login (as merchant)
$session = new Pap_Api_Session("http://localhost/pap/scripts/server.php"); 

//change it for your merchant panel login credentials here
if(!$session->login("merchant@username.com", "password")) { 
  die("Cannot login. Message: ".$session->getMessage());

// initiate a new grid request
$request = new Gpf_Rpc_Gridrequest("Gpf_Report_OnlineUsers", "getRows", $session);

// send request
try {
} catch(Exception $e) {
  die("API call error: ".$e->getMessage());

// request was successful, get the grid result
$grid = $request->getGrid();

// get recordset from the grid
$recordset = $grid->getRecordset();

foreach($recordset as $rec) {
	echo 'Name: '.$rec->get('firstname').' '.$rec->get('lastname').' Username: '.$rec->get('username').'<br>';