Project

General

Profile

How can I send a message using REST APi?

Peter Rajcani
Added about 4 years ago

Can I send a message using the HTTP REST API? I know that it supports publishing a message, what about sending a message from one user to another? What is the URL / sample request? Thanks!


Replies (3)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 4 years ago

Sending a message using HTTP REST API is relatively easy. The only drawback is that Tigase does not ship with a REST API call for sending messages to a single user. So you have to implement a call yourself. It is not difficult though. Just take a look at the script code for sending a message to all online users and modify it. Also, normally REST API calls are restricted to administrators, so keep this in mind. If you want to allow for sending messages between normal users through REST API, then it is possible but we strongly advise you not to do this.

Added by Peter Rajcani about 4 years ago

Thanks! Where can I find this script you mentioned? I looked into scripts/admin and I only found PublishItem.groovy from the PubSub API calls. Is that the one you are referring to? Our security requirements prevent us from using the XMPP protocol directly.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 4 years ago

BroadcastToOnline.groovy is the script I mentioned. However, in the same folder there is a number of other scripts which can server you well as example code.

    (1-3/3)