Search code examples
phpsteam

displaying user online status on steam


I want to display the user status (if they are online, offline, busy, etc).

My code :

  <p class="category"><?php echo $steamprofile['personastate']; ?></p>

When I use the above code it only display numbers, not the status label ("online","offline")

This is what I get:

The user's current state, 1 - Online, 2 - Busy, 3 - Away, 4 - Snooze, 5 - looking to trade, 6 - looking to play

If user is online it displays 1, offline 2.

I am using [steamauth library](https://github.com/SmItH197/SteamAuthentication ):

How I can covert the numbers to the status "online" or offline etc..


Solution

  • I think the best option to you is to create a local array where you put your pair id => Status, so you have something like this

    $statuses = array (1 => 'Online',2 => 'Busy' , 3 => ...); //Complete with all avaiable statuses
    echo $statuses[$steamprofile['personalstate']];
    

    This piece of code should make the trick