App Context API for PubNub PHP SDK

This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the migration guide.

App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to easily store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is set or removed from the database. Clients can receive these events in real time and update their front-end application accordingly.

User

Get Metadata for All Users

Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

Method(s)

To Get All UUID Metadata you can use the following method(s) in the PHP SDK:

getAllUUIDMetadata()
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync()
ParameterTypeRequiredDefaultDescription
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount or customFields and value is a boolean. Set customFields to fetch custom fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Basic Usage

$response = $pubnub->getAllUUIDMetadata()
->includeFields([ "totalCount" => true, "customFields" => true ])
->sync();

Response

The getAllUUIDMetadata() operation returns a PNGetAllUUIDMetadataResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNGetUUIDMetadataResult]List of uuid metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNGetUUIDMetadataResult which contains the following fields:

ParameterTypeDescription
getId()StringUnique user identifier
getName()StringDisplay name for the user
getExternalId()StringUser's identifier in an external system
getProfileUrl()StringThe URL of the user's profile picture
getEmail()StringThe user's email address
getCustom()stdClassObject containing your custom fields

Get User Metadata

Returns metadata for the specified UUID, including the custom data object for each.

Method(s)

To Get UUID Metadata you can use the following method(s) in the PHP SDK:

getUUIDMetadata()
->uuid(String)
->sync()
ParameterTypeRequiredDefaultDescription
uuid()StringYesUnique user identifier

Basic Usage

$response = $pubnub->getUUIDMetadata()
->uuid("uuid")
->sync();

Response

The getUUIDMetadata() operation returns a PNGetUUIDMetadataResult which contains the following fields:

ParameterTypeDescription
getId()StringUnique user identifier
getName()StringDisplay name for the user
getExternalId()StringUser's identifier in an external system
getProfileUrl()StringThe URL of the user's profile picture
getEmail()StringThe user's email address
getCustom()stdClassObject containing your custom fields

Set User Metadata

Set metadata for a UUID in the database, including the custom data object for each.

Method(s)

To Set UUID Metadata you can use the following method(s) in the PHP SDK:

setUUIDMetadata()
->uuid(String)
->meta(Array | StdClass)
->sync()
ParameterTypeRequiredDefaultDescription
uuid()StringYesUnique user identifier
meta()Array or StdClassYesUUID metadata to set.

UUID metadata contains the following fields:

FieldTypeRequiredDescription
nameStringOptionalDisplay name for the user.
externalIdStringOptionalUser's identifier in an external system.
profileUrlStringOptionalThe URL of the user's profile picture.
emailStringOptionalThe user's email address.
customArray or StdClassOptionalObject containing your custom fields. App Context filtering language doesn’t support filtering by custom properties.
API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Basic Usage

// using array metadata
$pubnub->setUUIDMetadata()
->uuid("uuid")
->meta([
"name" => "display_name",
"externalId" => "external_id",
"profileUrl" => "profile_url",
"email" => "email_address",
"custom" => [
"a" => "aa",
"b" => "bb"
]
])
->sync();

show all 33 lines

Response

The setUUIDMetadata() operation returns a PNSetUUIDMetadataResult which contains the following fields:

ParameterTypeDescription
getId()StringUnique user identifier
getName()StringDisplay name for the user
getExternalId()StringUser's identifier in an external system
getProfileUrl()StringThe URL of the user's profile picture
getEmail()StringThe user's email address
getCustom()stdClassObject containing your custom fields

Remove User Metadata

Removes the metadata from a specified UUID.

Method(s)

To Remove UUID Metadata you can use the following method(s) in the PHP SDK:

removeUUIDMetadata()
->uuid(String)
->sync()
ParameterTypeRequiredDefaultDescription
uuid()StringYesUnique user identifier

Basic Usage

$response = $pubnub->removeUUIDMetadata()
->uuid("uuid")
->sync();

Response

Returns a boolean, true for success otherwise false

Channel

Get Metadata for All Channels

Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

Method(s)

To Get All Channel Metadata you can use the following method(s) in the PHP SDK:

getAllChannelMetadata()
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync()
ParameterTypeRequiredDefaultDescription
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount or customFields and value is a boolean. Set customFields to fetch custom fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Basic Usage

$response = $pubnub->getAllChannelMetadata()
->includeFields([ "totalCount" => true, "customFields" => true ])
->sync();

Response

The getAllChannelMetadata() operation returns a PNGetAllChannelMetadataResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNGetChannelMetadataResult]List of channel metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNGetChannelMetadataResult which contains the following fields:

ParameterTypeDescription
getId()StringUnique channel identifier
getName()StringDisplay name for the channel
getDescription()StringDescription of a channel
getCustom()stdClassObject containing your custom fields

Get Channel Metadata

Returns metadata for the specified Channel, including the custom data object for each.

Method(s)

To Get Channel Metadata you can use the following method(s) in the PHP SDK:

getChannelMetadata()
->channel(String)
->sync()
ParameterTypeRequiredDefaultDescription
channel()StringYesUnique channel identifier

Basic Usage

$response = $pubnub->getChannelMetadata()
->channel("channel")
->sync();

Response

The getChannelMetadata() operation returns a PNGetChannelMetadataResult which contains the following fields:

ParameterTypeDescription
getId()StringUnique channel identifier
getName()StringDisplay name for the channel
getDescription()StringDescription of a channel
getCustom()stdClassObject containing your custom fields

Set Channel Metadata

Set metadata for a Channel in the database, including the custom data object for each.

Method(s)

To Set Channel Metadata you can use the following method(s) in the PHP SDK:

setChannelMetadata()
->channel(String)
->meta(Array | StdClass)
->sync()
ParameterTypeRequiredDefaultDescription
channel()StringYesUnique channel identifier
meta()Array or StdClassYesChannel metadata to set.

Channel metadata contains the following fields

FieldTypeRequiredDescription
nameStringOptionalDisplay name for the channel.
descriptionStringOptionalDescription of a channel.
customArray or StdClassOptionalObject containing your custom fields. App Context filtering language doesn’t support filtering by custom properties.
API limits

To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.

Basic Usage

// using array metadata
$pubnub->setChannelMetadata()
->channel("channel")
->meta([
"name" => "display_name",
"description" => "description_of_channel",
"custom" => [
"a" => "aa",
"b" => "bb"
]
])
->sync();

// using stdClass metadata
use stdClass;
show all 29 lines

Response

The setChannelMetadata() operation returns a PNSetChannelMetadataResult which contains the following fields:

ParameterTypeDescription
getId()StringUnique channel identifier
getName()StringDisplay name for the channels
getDescription()StringDescription of a channel
getCustom()stdClassObject containing your custom fields

Remove Channel Metadata

Removes the metadata from a specified channel.

Method(s)

To Remove Channel Metadata you can use the following method(s) in the PHP SDK:

removeChannelMetadata()
->channel(String)
->sync()
ParameterTypeRequiredDefaultDescription
channel()StringYesUnique channel identifier

Basic Usage

$response = $pubnub->removeChannelMetadata()
->channel("channel")
->sync();

Response

Returns a boolean, true for success otherwise false

Channel Memberships

Get Channel Memberships

The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.

Method(s)

To Get Memberships you can use the following method(s) in the PHP SDK:

getMemberships()
->uuid(String)
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
ParameterTypeRequiredDefaultDescription
uuid()StringYesUnique user identifier
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount, customFields, customChannelFields or channelFields and value is a boolean. Set customFields to fetch custom fields or not. Set customChannelFields to fetch custom channel fields or not. Set channelFields to fetch channel fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Basic Usage

$response = $pubnub->getMemberships()
->uuid("uuid")
->includeFields([ "totalCount" => true, "customFields" => true, "customChannelFields" => true, "channelFields" => true ])
->sync();

Response

The getMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNMembershipsResultItem]List of membership metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterTypeDescription
getChannel()PNMembershipChannel metadata
getCustom()StringstdClass object containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel is a PNMembership which contains the following fields:

ParameterTypeDescription
getId()StringUnique channel identifier
getName()StringDisplay name for the channel
getDescription()StringDescription of a channel
getCustom()stdClassObject containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Set Channel Memberships

Set channel memberships for a UUID.

Method(s)

To Set Memberships you can use the following method(s) in the PHP SDK:

setMemberships()
->uuid(String)
->channels(Array[String | Array])
->custom(Array | StdClass)
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
ParameterTypeRequiredDefaultDescription
uuid()StringYesUnique user identifier
channels()Array[String or Array]YesArray of channels to add to membership. Array can contain strings (channel-name only) or objects (which can include custom data).
custom()Array or StdClassYesObject of key-value pairs with supported data types.
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount, customFields, customChannelFields or channelFields and value is a boolean. Set customFields to fetch custom fields or not. Set customChannelFields to fetch custom channel fields or not. Set channelFields to fetch channel fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.
API limits

To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.

Basic Usage

$response = $pubnub->setMemberships()
->uuid("uuid")
->channels([
"ch",
[ id => "ch1" ],
[ id => "ch2", custom => [ hello => "world" ]]
])
->custom([
"a" => "aa",
"b" => "bb",
])
->includeFields([ "totalCount" => true, "customFields" => true, "customChannelFields" => true, "channelFields" => true ])
->sync();

Response

The setMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNMembershipsResultItem]List of membership metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterTypeDescription
getChannel()PNMembershipChannel metadata
getCustom()StringstdClass object containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel is a PNMembership which contains the following fields:

ParameterTypeDescription
getId()StringUnique channel identifier
getName()StringDisplay name for the channel
getDescription()StringDescription of a channel
getCustom()stdClassObject containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Remove Channel Memberships

Remove channel memberships for a UUID.

Method(s)

To Remove Memberships you can use the following method(s) in the PHP SDK:

removeMemberships()
->uuid(String)
->channels(Array[String])
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
ParameterTypeRequiredDefaultDescription
uuid()StringYesUnique user identifier.
channels()Array[String]YesArray of channels to remove from membership.
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount, customFields, customChannelFields or channelFields and value is a boolean. Set customFields to fetch custom fields or not. Set customChannelFields to fetch custom channel fields or not. Set channelFields to fetch channel fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Basic Usage

$response = $pubnub->removeMemberships()
->uuid("uuid")
->channels(["ch", "ch1", "ch2"])
->includeFields([ "totalCount" => true, "customFields" => true, "customChannelFields" => true, "channelFields" => true ])
->sync();

Response

The removeMemberships() operation returns a PNMembershipsResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNMembershipsResultItem]List of membership metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNMembershipsResultItem which contains the following fields:

ParameterTypeDescription
getChannel()PNMembershipChannel metadata
getCustom()StringstdClass object containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel is a PNMembership which contains the following fields:

ParameterTypeDescription
getId()StringUnique channel identifier
getName()StringDisplay name for the channel
getDescription()StringDescription of a channel
getCustom()stdClassObject containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel Members

Get Channel Members

The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.

Method(s)

To Get Channel Members you can use the following method(s) in the PHP SDK:

getMembers()
->channel(String)
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
ParameterTypeRequiredDefaultDescription
channel()StringYesUnique channel identifier
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount, customFields, customUUIDFields or UUIDFields and value is a boolean. Set customFields to fetch custom fields or not. Set customUUIDFields to fetch custom UUID fields or not. Set UUIDFields to fetch UUID fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Basic Usage

$response = $pubnub->getMembers()
->channel("channel")
->includeFields([ "totalCount" => true, "customFields" => true, "customUUIDFields" => true, "UUIDFields" => true ])
->sync();

Response

The getMembers() operation returns a PNMembersResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNMembersResultItem]List of member metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterTypeDescription
getUUID()PNMemberUUID metadata
getCustom()StringstdClass object containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel is a PNMember which contains the following fields:

ParameterTypeDescription
getId()StringUnique user identifier
getName()StringDisplay name for the user
getExternalId()StringUser's identifier in an external system
getProfileUrl()StringThe URL of the user's profile picture
getEmail()StringThe user's email address
getCustom()stdClassObject containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Set Channel Members

This method sets members in a channel.

Method(s)

To Set Channel Members you can use the following method(s) in the PHP SDK:

setMembers()
->channel(String)
->uuids(Array[String | Array])
->custom(Array | StdClass)
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
ParameterTypeRequiredDefaultDescription
channel()StringYesUnique channel identifier
uuids()Array[String or Array]YesArray of members to add to the channel. Array can contain strings (uuid only) or arrays/objects (which can include custom data).
custom()Array or StdClassYesObject of key-value pairs with supported data types.
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount, customFields, customUUIDFields or UUIDFields and value is a boolean. Set customFields to fetch custom fields or not. Set customUUIDFields to fetch custom UUID fields or not. Set UUIDFields to fetch UUID fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.
API limits

To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.

Basic Usage

$response = $pubnub->setMembers()
->channel("channel")
->uuids([
"uuid",
[ id => "uuid1" ],
[ id => "uuid2", custom => [ hello => "world" ]]
])
->custom([
"a" => "aa",
"b" => "bb",
])
->includeFields([ "totalCount" => true, "customFields" => true, "customUUIDFields" => true, "UUIDFields" => true ])
->sync();

Response

The setMembers() operation returns a PNMembersResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNMembersResultItem]List of member metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterTypeDescription
getUUID()PNMemberUUID metadata
getCustom()StringstdClass object containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel is a PNMember which contains the following fields:

ParameterTypeDescription
getId()StringUnique user identifier
getName()StringDisplay name for the user
getExternalId()StringUser's identifier in an external system
getProfileUrl()StringThe URL of the user's profile picture
getEmail()StringThe user's email address
getCustom()stdClassObject containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Remove Channel Members

Remove members from a Channel.

Method(s)

To Remove Channel Members you can use the following method(s) in the PHP SDK:

removeMembers()
->channel(String)
->uuids(Array[String])
->includeFields(Array[String => Boolean])
->filter(String)
->sort(String | Array[String])
->limit(Integer)
->page(Array[String => String])
->sync();
ParameterTypeRequiredDefaultDescription
channel()StringYesUnique channel identifier
uuids()Array[String]YesArray of members to remove from the channel
custom()Array or StdClassYesObject of key-value pairs with supported data types.
includeFields()Array[String => Boolean]OptionalInclude respective additional fields in the response. Key value array where keys are one of totalCount, customFields, customUUIDFields or UUIDFields and value is a boolean. Set customFields to fetch custom fields or not. Set customUUIDFields to fetch custom UUID fields or not. Set UUIDFields to fetch UUID fields or not. Set totalCount to request totalCount to be included in paginated response. By default, totalCount is omitted.
filter()StringOptionalExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here.
sort()String or Array[String]OptionalString or Array of String property names to sort by, and an optional sort direction. Available options are id, name, and updated. Use asc or desc to specify sort direction, or omit to take the default sort direction (ascending). For example: name:asc
limit()integerOptional100Number of objects to return in response. Default is 100, which is also the maximum value.
page()Array[String => String]OptionalUse for pagination. Key value array where keys are one of next or prev and value is a random string returned from the server, indicating a specific position in a data set. Set prev to a previously-returned string for fetching the previous page. Set next to a previously-returned string for fetching the next page.

Basic Usage

$response = $pubnub->removeMembers()
->channel("channel")
->uuids(["uuid", "uuid1", "uuid2"])
->includeFields([ "totalCount" => true, "customFields" => true, "customUUIDFields" => true, "UUIDFields" => true ])
->sync();

Response

The removeMembers() operation returns a PNMembersResult which contains the following fields:

ParameterTypeDescription
getData()Array[PNMembersResultItem]List of member metadata results
getTotalCount()IntegerNumber of items returned in the data
getPrev()StringRandom string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
getNext()StringRandom string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.

Data is an array of PNMembersResultItem which contains the following fields:

ParameterTypeDescription
getUUID()PNMemberUUID metadata
getCustom()StringstdClass object containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag

Channel is a PNMember which contains the following fields:

ParameterTypeDescription
getId()StringUnique user identifier
getName()StringDisplay name for the user
getExternalId()StringUser's identifier in an external system
getProfileUrl()StringThe URL of the user's profile picture
getEmail()StringThe user's email address
getCustom()stdClassObject containing your custom fields
getUpdated()StringThe last updated date and time
getETag()StringThe entity tag
Last updated on