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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNGetUUIDMetadataResult] | List of uuid metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique user identifier |
getName() | String | Display name for the user |
getExternalId() | String | User's identifier in an external system |
getProfileUrl() | String | The URL of the user's profile picture |
getEmail() | String | The user's email address |
getCustom() | stdClass | Object 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid() | String | Yes | Unique user identifier |
Basic Usage
$response = $pubnub->getUUIDMetadata()
->uuid("uuid")
->sync();
Response
The getUUIDMetadata()
operation returns a PNGetUUIDMetadataResult
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique user identifier |
getName() | String | Display name for the user |
getExternalId() | String | User's identifier in an external system |
getProfileUrl() | String | The URL of the user's profile picture |
getEmail() | String | The user's email address |
getCustom() | stdClass | Object 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid() | String | Yes | Unique user identifier | |
meta() | Array or StdClass | Yes | UUID metadata to set. |
UUID metadata contains the following fields:
Field | Type | Required | Description |
---|---|---|---|
name | String | Optional | Display name for the user. |
externalId | String | Optional | User's identifier in an external system. |
profileUrl | String | Optional | The URL of the user's profile picture. |
email | String | Optional | The user's email address. |
custom | Array or StdClass | Optional | Object 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 linesResponse
The setUUIDMetadata()
operation returns a PNSetUUIDMetadataResult
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique user identifier |
getName() | String | Display name for the user |
getExternalId() | String | User's identifier in an external system |
getProfileUrl() | String | The URL of the user's profile picture |
getEmail() | String | The user's email address |
getCustom() | stdClass | Object 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid() | String | Yes | Unique 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNGetChannelMetadataResult] | List of channel metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique channel identifier |
getName() | String | Display name for the channel |
getDescription() | String | Description of a channel |
getCustom() | stdClass | Object 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel() | String | Yes | Unique channel identifier |
Basic Usage
$response = $pubnub->getChannelMetadata()
->channel("channel")
->sync();
Response
The getChannelMetadata()
operation returns a PNGetChannelMetadataResult
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique channel identifier |
getName() | String | Display name for the channel |
getDescription() | String | Description of a channel |
getCustom() | stdClass | Object 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel() | String | Yes | Unique channel identifier | |
meta() | Array or StdClass | Yes | Channel metadata to set. |
Channel metadata contains the following fields
Field | Type | Required | Description |
---|---|---|---|
name | String | Optional | Display name for the channel. |
description | String | Optional | Description of a channel. |
custom | Array or StdClass | Optional | Object 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 linesResponse
The setChannelMetadata()
operation returns a PNSetChannelMetadataResult
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique channel identifier |
getName() | String | Display name for the channels |
getDescription() | String | Description of a channel |
getCustom() | stdClass | Object 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()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel() | String | Yes | Unique 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();
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid() | String | Yes | Unique user identifier | |
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNMembershipsResultItem] | List of membership metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getChannel() | PNMembership | Channel metadata |
getCustom() | String | stdClass object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |
Channel is a PNMembership
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique channel identifier |
getName() | String | Display name for the channel |
getDescription() | String | Description of a channel |
getCustom() | stdClass | Object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The 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();
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid() | String | Yes | Unique user identifier | |
channels() | Array[String or Array] | Yes | Array of channels to add to membership. Array can contain strings (channel-name only) or objects (which can include custom data). | |
custom() | Array or StdClass | Yes | Object of key-value pairs with supported data types. | |
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNMembershipsResultItem] | List of membership metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getChannel() | PNMembership | Channel metadata |
getCustom() | String | stdClass object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |
Channel is a PNMembership
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique channel identifier |
getName() | String | Display name for the channel |
getDescription() | String | Description of a channel |
getCustom() | stdClass | Object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The 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();
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
uuid() | String | Yes | Unique user identifier. | |
channels() | Array[String] | Yes | Array of channels to remove from membership. | |
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNMembershipsResultItem] | List of membership metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getChannel() | PNMembership | Channel metadata |
getCustom() | String | stdClass object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |
Channel is a PNMembership
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique channel identifier |
getName() | String | Display name for the channel |
getDescription() | String | Description of a channel |
getCustom() | stdClass | Object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The 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();
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel() | String | Yes | Unique channel identifier | |
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNMembersResultItem] | List of member metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getUUID() | PNMember | UUID metadata |
getCustom() | String | stdClass object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |
Channel is a PNMember
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique user identifier |
getName() | String | Display name for the user |
getExternalId() | String | User's identifier in an external system |
getProfileUrl() | String | The URL of the user's profile picture |
getEmail() | String | The user's email address |
getCustom() | stdClass | Object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The 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();
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel() | String | Yes | Unique channel identifier | |
uuids() | Array[String or Array] | Yes | Array of members to add to the channel. Array can contain strings (uuid only) or arrays/objects (which can include custom data). | |
custom() | Array or StdClass | Yes | Object of key-value pairs with supported data types. | |
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNMembersResultItem] | List of member metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getUUID() | PNMember | UUID metadata |
getCustom() | String | stdClass object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |
Channel is a PNMember
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique user identifier |
getName() | String | Display name for the user |
getExternalId() | String | User's identifier in an external system |
getProfileUrl() | String | The URL of the user's profile picture |
getEmail() | String | The user's email address |
getCustom() | stdClass | Object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The 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();
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel() | String | Yes | Unique channel identifier | |
uuids() | Array[String] | Yes | Array of members to remove from the channel | |
custom() | Array or StdClass | Yes | Object of key-value pairs with supported data types. | |
includeFields() | Array[String => Boolean] | Optional | Include 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() | String | Optional | Expression 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] | Optional | String 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() | integer | Optional | 100 | Number of objects to return in response. Default is 100 , which is also the maximum value. |
page() | Array[String => String] | Optional | Use 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:
Parameter | Type | Description |
---|---|---|
getData() | Array[PNMembersResultItem] | List of member metadata results |
getTotalCount() | Integer | Number of items returned in the data |
getPrev() | String | Random 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() | String | Random 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:
Parameter | Type | Description |
---|---|---|
getUUID() | PNMember | UUID metadata |
getCustom() | String | stdClass object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |
Channel is a PNMember
which contains the following fields:
Parameter | Type | Description |
---|---|---|
getId() | String | Unique user identifier |
getName() | String | Display name for the user |
getExternalId() | String | User's identifier in an external system |
getProfileUrl() | String | The URL of the user's profile picture |
getEmail() | String | The user's email address |
getCustom() | stdClass | Object containing your custom fields |
getUpdated() | String | The last updated date and time |
getETag() | String | The entity tag |