我知道我可以使用命令在ejabberd中创建聊天室
ejabberdctl create_room room_name muc_service xmpp_domain
并且我可以使用命令向用户发送邀请
ejabberdctl send_direct_invitation room_name password reason jid1[:jid2]
有人能告诉我如何使用ejabberd rest api做同样的事情吗?
我使用oauth进行身份验证。
我已经在ejabberd.yml文件中完成了以下配置
port: 5280 module: ejabberd_http request_handlers: "/websocket": ejabberd_http_ws "/log": mod_log_http "/oauth": ejabberd_oauth "/api": mod_http_api web_admin: true http_bind: true register: true captcha: true commands_admin_access: configure commands: - add_commands: - user - status oauth_expire: 3600 oauth_access: all
并且还在ejabberd.yml文件中启用了mod_muc_admin
modules: mod_muc_admin: {}
发布于 2016-07-25 08:32:10
使用mod_restful模块通过api访问ejabberd。如果您想要访问该模块,则需要在ejabberd.yml中配置以下行。
mod_restful:
api:
- path: ["admin"]
module: mod_restful_admin
params:
key: "secret"
allowed_commands: [register, unregister,status, add_rosteritem, create_room, send_direct_invitation, set_room_affiliation]
- path: ["register"]
module: mod_restful_register
params:
key: "secret"
它们是在allowed_commands中声明的命令,只有这些命令才能通过api访问。因此,将来如果您想访问任何其他命令,则需要在此处添加。
添加完成后,重新启动ejabberd,您可以使用postman或curl访问api。
/*
Data that need to be sent for creating group.
Url : example.com:8088/api/admin/
Content-Type: application/json
{"key": "secret","command": "create_room","args": ["group1","conference.example.com","example.com"]}
*/
与此类似的尝试也适用于send_direct_invitation ...
发布于 2016-07-25 08:24:26
为了完成创建房间的api请求,
做个卷发式,
curl -X POST -H "Cache-Control: no-cache" -d '{ "name": "aaaaa", "service": "bbbbb", "host": "ccccc" }' "http://localhost:5280/api/create_room"
或者,如果您想要在单个笔划中添加多个房间,则将所有房间名称添加到一个文件中,例如文件名为aaaaa
像这样卷曲,
curl -X POST -H "Cache-Control: no-cache" -d '{ "file": "aaaaa" }' "http://localhost:5280/api/create_rooms_file"
https://stackoverflow.com/questions/38538709
复制相似问题