Project

General

Profile

REST API: zarzadzanie pokojami czatowymi -- chatroom administration

Jan Niemiecki
Added about 3 years ago

Dzien dobry,

Uzywam Tigase od niedawna i ad hoc komendy dzialaja super.

Np, moge latwo zmienic haslo uzytkownika (skrypt ponizej).

Ja natomiast potrzebuje zarzadzac pokojami czatowymi przez REST API.

Gdzie moge znalezc podobne skrypty przykladowe do http://xmpp.org/extensions/xep-0045.html#createroom ?

Czy moze ktos pomoc?

Dziekuje.

Jan


Hi,

I've been using Tigase for a short time and I think ad hoc commands are great.

E.g., I can easily change user passwords (script below).

However, I'd need to administer chat rooms via REST API.

Where should I look for similar sample scripts for http://xmpp.org/extensions/xep-0045.html#createroom for instance?

Could anybody help?

Cheers.

Jan


$curl_log = fopen("curl_log.txt", "w") or die("Unable to open file!");
$res = curl_init("http://costam:8080/rest/adhoc/sess-man@costam.com");
curl_setopt($res,CURLOPT_HTTPHEADER,array('api-key: costam','Content-Type: application/json'));
curl_setopt($res, CURLOPT_POST, true);
curl_setopt($res, CURLOPT_USERPWD, "admin@costam.com:costam");
$post = '{ 
 "command" : {
   "node" : "http://jabber.org/protocol/admin#change-user-password",
   "fields" : [
     {
       "var" : "accountjid",
       "value" : "costam@costam.com" 
     },
     {
       "var" : "password",
       "value" : "costam" 
     }
   ]
 }
}';
curl_setopt($res, CURLOPT_POSTFIELDS, $post);
curl_setopt($res, CURLOPT_RETURNTRANSFER, true);
curl_setopt($res, CURLOPT_VERBOSE, true);
curl_setopt($res, CURLOPT_STDERR, $curl_log);        
$output = curl_exec($res);
print $output;
curl_close($res);

Replies (8)

Added by Wojciech Kapcia TigaseTeam about 3 years ago

Rest API access ad-hoc commands that are available on the server. In the context of MUC there are right now only a couple of them:

  • Default Room Config - changing default configuration;

  • Remove Room - deleting the room by administrator;

There is no command to create the room, but it could be easily created - please check the sources of current scripts in https://projects.tigase.org/projects/tigase-muc/repository/revisions/master/show/src/main/groovy/muc/admin

(1)

Added by Jan Niemiecki about 3 years ago

Thanks Wojciech!

The problem is that it's difficult to figure out what's going on in those scripts as some of the imports seem to be missing. For instance, tigase.server.Command.java imports among others:

  • tigase.xml.XMLUtils;

  • tigase.xmpp.JID;

  • tigase.xmpp.StanzaType;

of which only the last one can be found (https://projects.tigase.org/projects/tigase-server/repository/revisions/master/show/src/main/java/tigase)

The files tigase.xmpp.JID.java and the entire package tigase.xml are missing.

On the other hand, if I try to clone your repo (git version 2.6.3.windows.1) by typing git clone https://repository.tigase.org/git/tigase-server.git or git clone git://repository.tigase.org/git/tigase-server.git, it fails to connect:

fatal: unable to connect to repository.tigase.org:

repository.tigase.org[0: 198.27.120.208]: errno=No such file or directory

How can I access these missing files?

Cheers,

Jan

(1)

Added by Wojciech Kapcia TigaseTeam about 3 years ago

Jan Niemiecki wrote:

Thanks Wojciech!

The problem is that it's difficult to figure out what's going on in those scripts as some of the imports seem to be missing. For instance, tigase.server.Command.java imports among others:

  • tigase.xml.XMLUtils;

  • tigase.xmpp.JID;

  • tigase.xmpp.StanzaType;

of which only the last one can be found (https://projects.tigase.org/projects/tigase-server/repository/revisions/master/show/src/main/java/tigase)

The files tigase.xmpp.JID.java and the entire package tigase.xml are missing.

I'm not sure I'm following. Those are Tigase XMPP Server APIs (and you should access the groovy admin ad-hoc scripts from running Tigse instance hence the access to the aforementioned API).

OK, Tigase has to major dependencies - Tigase Utils and Tigase XML Tools During building of Tigase Server, those are being inlined in tigase-server binary.

On the other hand, if I try to clone your repo (git version 2.6.3.windows.1) by typing git clone https://repository.tigase.org/git/tigase-server.git or git clone git://repository.tigase.org/git/tigase-server.git, it fails to connect:

fatal: unable to connect to repository.tigase.org:

repository.tigase.org[0: 198.27.120.208]: errno=No such file or directory

How can I access these missing files?

This is weird, it works for me:

wojtek@atlantiscity.local ~/dev/tmps $ git clone https://repository.tigase.org/git/tigase-server.git
Cloning into 'tigase-server'...
remote: Counting objects: 43471, done.
remote: Compressing objects: 100% (11457/11457), done.
remote: Total 43471 (delta 28859), reused 39004 (delta 25499)
Receiving objects: 100% (43471/43471), 36.57 MiB | 1.93 MiB/s, done.
Resolving deltas: 100% (28859/28859), done.
Checking connectivity... done.

Are you behind some kind of proxy?

(1)

Added by Jan Niemiecki about 3 years ago

Ta, Wojciech! Now I can see all the files I've needed so far; so cloning's not important any more.

Thanks for your help.

Jan

(1)

Added by Jan Niemiecki about 3 years ago

Hi again!

I've been wondering, is there a way to bypass the groovy part and send pure iq messages to the server - for instance via cURL ?

If this is possible, what would be the url to send post requests to?

Thanks,

Jan

(1)

Added by Wojciech Kapcia TigaseTeam about 3 years ago

Currently it's not possible.

(1)
Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 3 years ago

I think it should be quite simple to add this functionality through the ad-hoc command in Groovy and REST API call.

Added by Wojciech Kapcia TigaseTeam almost 3 years ago

Actually it's already implemented - please check either REST API documentation from your running instance or HTTP API wiki: https://projects.tigase.org/projects/tigase-http-api/wiki/Usage_examples/edit#Sending-any-XMPP-Stanza

    (1-8/8)