PHPPHP V4 Channel Groups API Reference for Realtime Apps

Go to Access Manager


 

These docs are for PubNub 4.x for PHP which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.x for PHP.

If you have questions about the PubNub for PHP SDK, please contact us at support@pubnub.com.

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function adds a channel to a channel group.
Adding Channels is accomplished by using the following method(s) in the PHP V4 SDK:
 

200 channels can be added to the channel group per API call.

  1. ParameterTypeRequiredDescription
    channelsString|ArrayYesThe channels to add to the channel group.
    channelGroupStringYesThe channelGroup to add the channels to.
$pubnub->addChannelToChannelGroup()
    ->channels(["ch1", "ch2"])
    ->channelGroup("cg1")
    ->sync();
{
    "service" : "channel-registry",
    "status"  : 200,
    "error"   : false,
    "message" : "OK"
}
Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function lists all the channels of the channel group.
Listing Channels is accomplished by using the following method(s) in the PHP V4 SDK:
  1. ParameterTypeRequiredDescription
    channelGroupStringYesThe channel group to fetch channels.
$pubnub->listChannelsInChannelGroup()
    ->channelGroup("cg1")
    ->sync();
{
	"status" : 200,
	"payload" : {
		"channels" : ["hi"], 
		"group" : "abcd"
	},
	"service" : "channel-registry",
	"error" : False
}
Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channels from the channel group.
Removing Channels is accomplished by using the following method(s) in the PHP V4 SDK:
  1. ParameterTypeRequiredDescription
    channelsString|ArrayYeschannels to remove from the channel group.
    channelGroupStringYesSpecifies ChannelGroup to remove.
$pubnub->removeChannelFromChannelGroup()
    ->channels("son")
    ->channelGroup("family")
    ->sync();
{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}
Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channel group.
Deleting Channel Group is accomplished by using the following method(s) in the PHP V4 SDK:
  1. ParameterTypeRequiredDescription
    channelGroupStringYesThe channelGroup to remove.
$pubnub->removeChannelGroup()
    ->channelGroup("family")
    ->sync();
{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}

Go to Storage and Playback