Help with NextTalk Chat API

So for users (as already posted above) something like this works

curl -u user:password 'https://<nextcloudurl>/ocs/v2.php/apps/spreed/api/v1/chat/<token>' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H "OCS-APIRequest: true" \
  --data-raw '{"message":"test123"}'

For guests it’s a bit more tricky, because guests are identified per session (based on cookies). So you first have to join the conversation (and save the cookie) and then send a message (and use the cookie). Something like this:

curl 'https://<nextcloudurl>/ocs/v2.php/apps/spreed/api/v4/room/<token>/participants/active' \
  -b nc_cookies.txt \
  -c nc_cookies.txt \
  -H 'accept: application/json, text/plain, */*' \
  -H 'content-type: application/json' \
  -H "OCS-APIRequest: true" \
  --data-raw '{"force":true}'

curl 'https://<nextcloudurl>/ocs/v2.php/apps/spreed/api/v1/chat/<token>' \
  -b nc_cookies.txt \
  -c nc_cookies.txt \
  -H 'content-type: application/json' \
  -H "OCS-APIRequest: true" \
  --data-raw '{"message":"test", "actorDisplayName": "Guest"}'

Could also have a third request to leave the conversation again.

1 Like