Pubnub

PubNub 3.6 Real-time Push Cloud API

package

Pubnub

Methods

Pubnub Client API constructor

__construct(string|array $first_argument = '', string $subscribe_key = '', boolean|string $secret_key = false, boolean $cipher_key = false, boolean $ssl = false, boolean|string $origin = false, boolean $pem_path = false, boolean $uuid = false, boolean $proxy = false, boolean $auth_key = false) 

You can create client instance using named or positional arguments

throws

Arguments

$first_argument

string|array

publish_key to send messages or associative config array.

$subscribe_key

string

required key to receive messages.

$secret_key

boolean|string

optional key to sign messages.

$cipher_key

boolean

$ssl

boolean

required for 2048 bit encrypted messages.

$origin

boolean|string

optional setting for cloud origin.

$pem_path

boolean

$uuid

boolean

$proxy

boolean

$auth_key

boolean

Reveal existing permissions

audit(string|null $channel = null, string|null $auth_key = null) : array

Arguments

$channel

string|null

$auth_key

string|null

Response

array

Prepare default query

defaultQueryArray() : array

Response

array

detailedHistory

detailedHistory() 
deprecated 3.7.0
see \Pubnub\Pubnub->history()

Use history() instead

Returns metadata for user with given uuid

getState(string $channel, string $uuid) : array|null
throws

Arguments

$channel

string

$uuid

string

Response

array|null

Returns current UUID

getUUID() : string

Response

string

UUID

Establish subscribe and/or write permissions

grant(boolean $read, boolean $write, string|null $channel = null, string|null $auth_key = null, integer|null $ttl = null) : array

Arguments

$read

boolean

$write

boolean

$channel

string|null

$auth_key

string|null

$ttl

integer|null

Response

array

handleError

handleError(\Exception $error) 

for internal error handling

Arguments

$error

\Exception

Gets a list of uuids subscribed to the channel.

hereNow(string $channel = null, boolean $disable_uuids = false, boolean $state = false) : array
throws

Arguments

$channel

string

$disable_uuids

boolean

$state

boolean

Response

array

of uuids and occupancies.

Retrieve the messages on a channel

history(string $channel, integer $count = 100, boolean $include_token = null, integer $start = null, integer $end = null, boolean $reverse = false) : array
throws

Arguments

$channel

string

$count

integer

message limit

$include_token

boolean

for each message

$start

integer

time token

$end

integer

time token

$reverse

boolean

Response

array

leave

leave( $channel) 

Arguments

$channel

Return PubnubPAM instance

pam() : \Pubnub\PubnubPAM

Pipelines multiple requests into a single connection.

pipeline(Callback $callback) 

For PHP <= 5.3 use pipelineStart() and pipelineEnd() functions instead.

Arguments

$callback

Callback

End collecting messages and send them in pipelined mode.

pipelineEnd() 

Start collecting messages to send them in pipelined mode.

pipelineStart() 

Presence

presence(string $channel, callback $callback, integer $timeToken) 

This is BLOCKING. Listen for a message on a presence channel.

Arguments

$channel

string

$callback

callback

$timeToken

integer

Publish

publish(string $channel, string $messageOrg) : array

Sends a message to a channel.

throws

Arguments

$channel

string

$messageOrg

string

Response

array

success information.

Performs request depending on pipelined/non-pipelined mode

request(array $path, array $query = array(), boolean $useDefaultQueryArray = true) : array|null

In pipelined mode null is returned for every query In non-pipelined mode response array is returned

throws

Arguments

$path

array

$query

array

$useDefaultQueryArray

boolean

Response

array|null

Revoke all permissions

revoke(string|null $channel = null, string|null $auth_key = null) : array

Arguments

$channel

string|null

$auth_key

string|null

Response

array

Set auth_key after instantiation

setAuthKey( $auth_key) 

Arguments

$auth_key

Set metadata for user with given uuid

setState(string $channel, array|null $state, string|null $uuid = null) : mixed|null
throws

Arguments

$channel

string

$state

array|null

$uuid

string|null

Response

mixed|null

Updates current UUID

setUUID(string $uuid) 
throws

Arguments

$uuid

string

Subscribe

subscribe(string $channel, string $callback, integer $timeToken, boolean $presence = false) 

This is BLOCKING. Listen for a message on a channel.

throws

Arguments

$channel

string

for channel name

$callback

string

for callback definition.

$timeToken

integer

for current time token value.

$presence

boolean

throwAndResetTimeToken

throwAndResetTimeToken( $callback,  $errorMessage) : string

Arguments

$callback

$errorMessage

Response

string

Time

time() : integer

Timestamp from PubNub Cloud.

Response

integer

timestamp.

UUID

uuid() : string
static

UUID generator

Response

string

UUID

Returns channel list for defined UUID

whereNow(string $uuid = "") : array
throws

Arguments

$uuid

string

Response

array

Constants

PNSDK

PNSDK

Properties

ORIGIN

ORIGIN : 

Type(s)

PUBLISH_KEY

PUBLISH_KEY : 

Type(s)

SUBSCRIBE_KEY

SUBSCRIBE_KEY : 

Type(s)

SECRET_KEY

SECRET_KEY : 

Type(s)

CIPHER_KEY

CIPHER_KEY : 

Type(s)

AUTH_KEY

AUTH_KEY : 

Type(s)

SSL

SSL : 

Type(s)

SESSION_UUID

SESSION_UUID : 

Type(s)

PROXY

PROXY : 

Type(s)

NEW_STYLE_RESPONSE

NEW_STYLE_RESPONSE : 

Type(s)

pipelinedFlag

pipelinedFlag : 

Type(s)

defaultClient

defaultClient : 

Type(s)

pipelinedClient

pipelinedClient : 

Type(s)

AES

AES : 

Type(s)

PAM

PAM : 

Type(s)