PHP V4 Channel Groups API Reference for Realtime Apps
Channel Groups allows PubNub developers to bundle thousands of channels into a group that can be identified by name. These Channel Groups can then be subscribed to, receiving data from the many backend-channels the channel group contains.
Learn more about our Channel Groups here.
Adding Channels
Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function adds a channel to a channel group.
Method(s)
Adding Channels
is accomplished by using the following method(s) in the PHP V4 SDK:
Note
200 channels
can be added to the channel group
per API call.
$pubnub->addChannelToChannelGroup()->channels(string|array)->channelGroup(string)->sync();
Parameter Type Required Description channels
String|Array Yes The channels
to add to the channel group.channelGroup
String Yes The channelGroup
to add the channels to.
Basic Usage
$pubnub->addChannelToChannelGroup()
->channels(["ch1", "ch2"])
->channelGroup("cg1")
->sync();
Rest Response from Server
{
"service" : "channel-registry",
"status" : 200,
"error" : false,
"message" : "OK"
}
Listing Channels
Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function lists all the channels of the channel group.
Method(s)
Listing Channels
is accomplished by using the following method(s) in the PHP V4 SDK:
$pubnub->listChannelsInChannelGroup()->channelGroup(string)->sync();
Parameter Type Required Description channelGroup
String Yes The channel group
to fetch channels.
Basic Usage
$pubnub->listChannelsInChannelGroup()
->channelGroup("cg1")
->sync();
Rest Response from Server
{
"status" : 200,
"payload" : {
"channels" : ["hi"],
"group" : "abcd"
},
"service" : "channel-registry",
"error" : False
}
Removing Channels
Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function removes the channels from the channel group.
Method(s)
Removing Channels
is accomplished by using the following method(s) in the PHP V4 SDK:
$pubnub->removeChannelFromChannelGroup()->channels(string|array)->channelGroup(string)->sync();
Parameter Type Required Description channels
String|Array Yes channels
to remove from the channel group.channelGroup
String Yes Specifies ChannelGroup
to remove.
Basic Usage
$pubnub->removeChannelFromChannelGroup()
->channels("son")
->channelGroup("family")
->sync();
Rest Response from Server
{
"status" : 200,
"message" : "OK",
"service" : "channel-registry",
"error" : False
}
Deleting Channel Group
Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function removes the channel group.
Method(s)
Deleting Channel Group
is accomplished by using the following method(s) in the PHP V4 SDK:
$pubnub->removeChannelGroup()->channelGroup(string)->sync();
Parameter Type Required Description channelGroup
String Yes The channelGroup
to remove.
Basic Usage
$pubnub->removeChannelGroup()
->channelGroup("family")
->sync();
Rest Response from Server
{
"status" : 200,
"message" : "OK",
"service" : "channel-registry",
"error" : False
}