Thursday, May 15, 2014

The Paphus Live Chat web API

In addition to being able to embed your live chat channel on your own website, and access them from any Android device, you can also access your channel through the Paphus Live Chat web API. The web API gives you the advantage of having complete control of your channel's client interface.

You can use the web API to access your channel from your own website through JavaScript, PHP or any other language. You can also use the web API to create your own mobile application to access your channel, such as an Android or iOS application.

A web API, is a set of HTTP GET/POST URI's that allow sending and receiving of message data. When you browse a website, your browser makes a series of HTTP GET/POST requests to URIs that return HTML content. In a web service the URIs return XML or JSON data, instead of HTML content.

The LIVE CHAT libre web API consists of two parts, a REST API with XML message content, and a web sockets API for distributed communication. The REST API takes HTTP POST XML data, and returns XML data.

HTTP XML POST API

  • http://www.paphuslivechat.com/rest/livechat/create-user
  • http://www.paphuslivechat.com/rest/livechat/check-user
  • http://www.paphuslivechat.com/rest/livechat/get-channels
  • http://www.paphuslivechat.com/rest/livechat/check-channel

create-user

The create-user API creates a new user, and returns the user's details.

URI: http://www.paphuslivechat.com/rest/livechat/create-user
Parameters: application, user, password, hint, name, showName, email, website, bio

XML POST Example

check-user

The check-user API validates a user, and returns the user's details.

URI: http://www.paphuslivechat.com/rest/livechat/check-user
Parameters: application, user, password, token

Parameters

applicationREQUIRED: The application ID. You can obtain an application ID from your user details page on the LIVE CHAT libre website.
userREQUIRED: The ID of the user.
passwordREQUIRED: The password of the user. A token can also be used.
tokenREQUIRED: The token of the user. A token can be obtained through check-user, and is valid until reset.

XML POST Example

get-channels

The get-channels API queries the details for all channels matching the criteria.

URI: http://www.paphuslivechat.com/rest/livechat/get-channels
Parameters: application, user, password, token, type, tag, category, sort, typeFilter, filter.

XML POST Example

check-channel

The check-channel API validates that a channel ID or name exists, and returns the channel's details.

URI: http://www.paphuslivechat.com/rest/livechat/check-channel
Parameters: application, user, password, token, id, name

Parameters

applicationREQUIRED: The application ID.
userOPTIONAL: The ID of the user. The user must be registered with FORUMS libre. If not passed the user will be anonymous. The user is required if the forum is private.
passwordOPTIONAL: The password of the user. A token can also be used.
tokenOPTIONAL: The token of the user. A token can be obtained through check-user, and is valid until reset.
idREQUIRED: The ID of the channel to validate. The channel's name can also be used, but the ID is better as it is guaranteed to be unique.
nameREQUIRED: The name of the channel to validate. The channel's ID can also be used.

XML POST Example

Web Socket API

The web socket API uses web sockets to communicate with the LIVE CHAT libre server. Most web browsers support web sockets from JavaScript, you can also get free open source web socket implementations for most programming languages, and mobile platforms.

Here is some example web socket code using JavaScript in a web browser. It assumes an HTTP connection has already been made to the LIVE CHAT libre server. If you have not connected to a channel through a web session, you can still establish a connection. Once you establish a connection, you will need to send a text message to connect to a channel of the form "connect channel-id user password application-id".

So, that is the basic web API. You can now build your own interface for your channel. You can use the API on your own website, or in your own mobile application.

No comments:

Post a Comment