国外聊天IM — Sendbird

接⼝⽂档: https://sendbird.com/docs
好久没写文章了
我在官网找到的pom,  下载不下来,git下载下来,打进项目里不能用,就只能用简单的http了
直接上代码,只是简单的调通代码,根据你自己业务改:
//创建用户
public static void main(String[] args) {
        // ============ 接口url ================
        //{ application_id } 平台获取的appid
        String url="https://api- { application_id } .sendbird.com/v3/users";


        // ============ 请求body ================
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("user_id", "用户id");
        jsonObject.put("nickname", "昵称");
        jsonObject.put("profile_url", "https://sendbird.com/main/img/profiles/profile_05_512px.png");

        // ============ 添加请求头信息 ================
        Map<String, String> heads = new HashMap<>();
        // 使用json发送请求,下面的是必须的
        heads.put("Content-Type", "application/json");
        heads.put("Api-Token", "平台获取token");

        // ============ 发送请求 ================
        HttpResponse response = HttpRequest.post(url)
            .headerMap(heads, false)
            .body(String.valueOf(jsonObject))
            .timeout(5 * 60 * 1000)
            .execute();
        // ============ 打印结果 ================
        System.out.println("============ \u6253\u5370\u7ED3\u679C ================");
        System.out.println(response);
    }

// 用户列表
public static void main(String[] args) {
        //平台获取的appid
        String url="https://api-{ application_id }.sendbird.com/v3/users";
        url += "?limit=3&active_mode=activated";
        // 链式构建请求
        Map<String,Object> paramMap = new HashMap<>();
        HttpResponse httpResponse = HttpRequest.get(url)
            .header("Api-Token", "平台获取的token")// 头信息,多个头信息多次调用此方法即可
            .form(paramMap)//表单内容
            .timeout(1000)
            .execute();

        int status = httpResponse.getStatus();
        System.out.println(httpResponse.body());
    }

可以在后端注册im  剩下的操作在app端的sdk处理
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值