1. 创建房间

创建用房间

POST:http://api.xdua.com/room

只有户群主root才有权利创建room.

字段名 字段位置 字段类型 字段说明 举例 必选
apiv head string API版本,默认是1.0.0 1.0.0 可选
Authorization head string 客户端保存的鉴权token Authorization字符串 必选
code body string 房间的代号 255个字符以内 必选
name body string 房间的名字 16个字符以内 必选
brief body string 房间的简介 64个字符以内,必须是英文或者数字 必选
avatar body string 房间图标 必须 必选

BrowserSDK调用代码

const lovearth = require('../lib')
async function test_addroom() {
    //--------------------------------------------------
    const dua = await lovearth({
        APP_KEY: "您的appkey",
        APP_SECRET: "您的appsecret",
    })

    api_name = "创建房间";
    got_room_id = "";
    await dua.login({
        by  :   "tel",
        ustr:   '+86-15810419011',
        pwd :   'a906449d5769fa7361d7ecc6aa3f6d28',
        room:   "XdUaXduA",
        role:   "none"
    })

    const res = await dua.addroom({
        name:"测试房间",
        brief:"这是一个测试用的房间", 
        avatar:"",
        pid:"户群的id",
        god_id:"管理员的id"
    })
    console.log(res);
    if(res.error == 0){
        got_room_id = res.result.id;
        console.log(api_name+"成功 "+got_room_id);
    }else{
        got_room_id = res.result.id;
        console.log(api_name+"失败 "+res.reason);
    }

}

test_addroom();

1.1. 成功的返回

返回的id便是新创建的room的id.

{
    "error": 0,
    "reason": "Success",
    "result": ["id"=>"3bc8d2bf"]
}

1.2. 失败的返回

{
    "error": 1,
    "reason": "失败原因",
    "result": {"失败返回的参考数据"}
}

results matching ""

    No results matching ""