Search code examples
phpserver-sidechannelpusheruser-presence

Pusher: Getting user names within presence channel


With the server-side PHP SDK, I know we can currently get a list of users in a presence channel with

$response = $pusher->get( '/channels/'.$channelName.'/members' );

But is there any way to get the NAME of the user?


Solution

  • If you use the GET /apps/[app_id]/channels/[channel_name]/users method then you'll be able to get a list of people connected to a Presence Channel including their user ID. It's up to you to connect that user ID to a name from whatever system you use to manage users. http://pusher.com/docs/rest_api#users

    You could also combine this with Presence Channel Webhooks to be notified of new people in the channel (with their ID) as they connect http://pusher.com/docs/webhooks#presence