Introduction

Publish lets you send a message to a channel.

Valid/Success responses

Returns a three-element array:

  • Array element 0 - (Integer) 1 or 0, where 1 is a success, and 0 is an error.
  • Array element 1 - (String) Description of the success or error, if available.
  • Array element 2 - (String) The current PubNub time expressed as a timetoken.

Example

A sample response from the server [1,"Sent","14375189629170609"] contains the following fields:

  • The first element is an integer of value 1 representing success.
  • The second element is a string description of the success, which for 200 response codes will always be "Sent."
  • The third element is the string timetoken value the system accepted the Publish operation at.

Invalid/Error responses

Errors specific to Publish will occur when the URL (for example, message payload) is too large (>=32K) and invalid publish and/or subscribe keys are used.

In the event of an error, you will receive a non-200 HTTP status code and a two-element array. You can parse the second element of the returned array for a description of the error.