获取用户站点

Baklib
Baklib 最后一次编辑 接近 4 年前
156

基本信息

接口名称: 获取用户拥有的站点

接口类型: 数据获取

接口说明: 获取用户拥有的站点

详细信息

URL

http://www.baklib-free.com/api/v1/user/tenants

完整URL示例

http://www.baklib-free.com/api/v1/user/tenants

HTTP请求方式

GET

授权认证方式

默认方式,需要添加请求header

conn = Faraday.new(url: url)
conn.headers['Authorization'] = "Bearer #{token}"

请求参数

点击获取Token值

示例代码

require 'faraday'
require 'json'
host = 'http://www.baklib-free.com/'

client = Faraday.new(url: host) do |conn|
  conn.headers['Authorization'] = "Bearer #{token}"
  conn.headers['Content-Type'] = 'application/json'
  conn.adapter :net_http
end

response = client.get('/api/v1/user/tenants')
JSON.parse(response.body)

返回结果

{
  "code": 0,
  "status": "success",
  "message": {
    "mine": [
      {
        "id": "53e1293f-ea23-41c6-846e-a070522a5143",
        "name": "baklib_api_doc",
        "identifier": "tmapidoc",
        "domain": null,
        "site_title": null,
        "site_slogan": null,
        "site_logo": null,
        "site_icon": null,
        "site_color": null,
        "created_at": "2020-03-31T18:21:17.817+08:00",
        "updated_at": "2020-03-31T18:21:18.018+08:00",
        "user": {
          "id": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
          "mobile_phone": "15328077520",
          "name": "xiaohui",
          "image": "https://gitlab.tanmer.com/uploads/-/system/user/avatar/1/avatar.png",
          "email": null
        },
        "access_level": 0,
        "site_header_image": null,
        "icp_info": null,
        "plan": 0,
        "plan_expires_at": null,
        "site_header_mask": null,
        "allow_robots": false
      },
      {
        "id": "682c1cf8-41bf-4417-aa05-3e682fb5174b",
        "name": "接口开发文档说明",
        "identifier": "baklibapidoc",
        "domain": null,
        "site_title": null,
        "site_slogan": null,
        "site_logo": null,
        "site_icon": null,
        "site_color": null,
        "created_at": "2020-04-01T11:10:15.736+08:00",
        "updated_at": "2020-04-01T11:36:27.919+08:00",
        "user": {
          "id": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
          "mobile_phone": "15328077520",
          "name": "xiaohui",
          "image": "https://gitlab.tanmer.com/uploads/-/system/user/avatar/1/avatar.png",
          "email": null
        },
        "access_level": 0,
        "site_header_image": null,
        "icp_info": "蜀ICP备15035023号 - 13",
        "plan": 0,
        "plan_expires_at": null,
        "site_header_mask": null,
        "allow_robots": false
      }
    ],
    "shared": []
  }
}

返回字段说明

返回值字段 字段类型 说明
code Integer 状态码
status String 返回状态
id String 站点ID
name String 站点名称
identifier String 站点唯一标识符
domain String 二级域名
site_title String 网站名称 (可能是多余字段)
site_slogan String 宣传标语
site_logo String 站点logo
site_icon String 导航栏logo
site_color String 站点主题颜色
created_at Datetime 创建时间
updated_at Datetime 更新时间
user Obj 站点所有者
      id String 用户id
      mobile_phone String 用户手机号
      name String 用户名称
      image String 用户头像
      email String 用户邮箱
access_level Integer 访问类型
site_header_image String 标语图片
icp_info String 备案信息
plan Integer 购买的版本
plan_expires_at Datetime 版本到期时间
site_header_mask String 标语图蒙版颜色
allow_robots boolean 允许搜索引擎收录