【问题标题】:ejabberd mod_http_api rest requestejabberd mod_http_api 休息请求
【发布时间】:2016-07-14 02:14:09
【问题描述】:

我正在尝试发出一些休息请求(没有 OAuth),但 ejabberd 响应始终是“HTTP/1.1 400 Bad Request”

详情如下:

ejabberd 版本: 16.02

ejabberd 配置

port: 5280
    ip: "::"
    module: ejabberd_http
    request_handlers:
      ##"/websocket": ejabberd_http_ws
      ##"/oauth": ejabberd_oauth
      "/api": mod_http_api
    ##  "/pub/archive": mod_http_fileserver
    web_admin: true
    http_bind: true
    http_poll: true
    ## register: true
    captcha: false
    commands_admin_access: configure
    commands:
      - add_commands: user
    oauth_expire: 3600
    oauth_access: all

请求

curl -v -X POST -H "X-Admin: true" -H "Authorization: Basic YWRtaW5AcHJqLmlvOmFkbWlu"  -H "Content-Type:application/json" http://prj.io:5280/api/status -d '{}'

日志

2016-03-26 04:38:04.711 [debug] <0.490.0>@ejabberd_http:process_header:281 (#Port<0.16265>) http query: 'POST' <<"/api/status">>
2016-03-26 04:38:04.711 [debug] <0.490.0>@ejabberd_http:extract_path_query:395 client data: <<"{}">>
2016-03-26 04:38:04.711 [debug] <0.490.0>@ejabberd_http:process:353 [<<"api">>,<<"status">>] matches [<<"api">>]
2016-03-26 04:38:04.711 [info] <0.490.0>@mod_http_api:log:388 Admin call status [] from ::FFFF:192.168.117.1:53583

请帮助我了解 ejabberd 的行为以及向mod_http_api 发布一些请求的方式。

【问题讨论】:

  • 我无法生成令牌,为此苦苦挣扎了将近 3 天,而且我是 ejabbberd 的新手,这是我使用的配置。端口:5280 模块:ejabberd_http request_handlers: "/websocket": ejabberd_http_ws # OAuth 支持 "/oauth": ejabberd_oauth # ReST API: "/api": mod_http_api ## "/pub/archive": mod_http_fileserver web_admin: true http_bind: true register : true 验证码: false commands_admin_access: 配置命令: - add_commands: user oauth_expire: 3600 oauth_access: all
  • 尝试实现这个answer

标签: ejabberd ejabberd-api


【解决方案1】:

请求你已经给予,

curl -v -X POST -H "X-Admin: true" -H "Authorization: Basic YWRtaW5AcHJqLmlvOmFkbWlu" -H "Content-Type:application/json" http://prj.io:5280/api/status -d '{}'.

没有这样的终点状态

尝试以下方法之一作为您的端点,

  1. num_active_users - 最近几天活跃的用户数
  2. status_num_host - 在主机中具有给定状态的登录用户数
  3. status_num - 具有给定状态的登录用户数
  4. stats - 获取统计值:注册用户、在线用户、在线用户节点、正常运行时间秒数 stats_host - 获取每个主机的统计值:注册用户、在线用户、在线用户节点、正常运行时间秒数

【讨论】:

    【解决方案2】:

    试试下面的...

    commands_admin_access:配置 命令: - 添加命令: - 状态

    【讨论】:

      猜你喜欢
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      相关资源
      最近更新 更多