Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
P portal
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
Collapse sidebar
  • 科探开源
  • portal
  • Wiki
    • 门户v2 api 文档
  • 04.Message Subscription API v2

Last edited by asdu Dec 21, 2020
Page history

04.Message Subscription API v2

1.1 Subscription API 概述

  • Subscription API 是所有subscription接口的统称
  • Subscription API 有多种设置、更新、删除接口,具体的接口如下:
    • 增加单个Subscription
    • 删除、查询、删除单个Subscription
    • 查询用户相关的Subscription
  • 新增subscription接口:https://{site}/portal/api/v2/subscription/{bundle} POST
  • 删除、更新、查询单个subscription接口:https://{site}/portal/api/v2/subscription/{bundle}/{uuid} GET, PATCH, DELETE
  • 查询用户相关的subscription接口: https://{site}/portal/api/v2/subscription?_format=json GET
  • 如需要额外接口满足项目需求,可以通过后台使用Portal Views配置

1.2.Subscription API 新增单个数据

POST /portal/api/v2/subscription/{bundle} HTTP/1.1
Host: etl.dd:8083
Content-Type: application/vnd.api+json
Authorization: Bearer 50c8f237ecc91ac3f151e9d3cc615726
Accept: application/vnd.api+json

{
  "data": {
    "type": "subscription--{bundle}",
    "attributes": {
      "title": "新闻公告订阅",
      "target_id": "88981",
      "action":"collection",
      "status":1,
      "uuid":"18926ba9-4a93-429d-ae63-27836af5d369"
    },
    "relationships": {
      "target_type": {
        "data": { "type": "taxonomy_term--subscription_target_type", "id": "18926ba9-4a93-429d-ae63-27836af5d366" }
      }
    }
  }
}

1.2.1.Subscription API 新增单个数据的请求参数

具体的字段如下: 参数名 类型 是否必需 描述
type string 是 bundle可设置subscription
title string 否 标题
target_type int 是 订阅类型分类
action string 是 默认值like,collection, follow, comment,post, update,subscribe
target_id string 是 订阅栏目id

1.3 更新单个数据

PATCH /portal/api/v2/subscription/{bundle}/{uuid} HTTP/1.1
Host: etl.dd:8083
Content-Type: application/vnd.api+json
Authorization: Bearer 50c8f237ecc91ac3f151e9d3cc615726
Accept: application/vnd.api+json

{
  "data": {
    "type": "subscription--{bundle}",
    "id": "{uuid}"
    "attributes": {
      "title": "新闻公告订阅",
      "target_id": "88981",
      "action":"collection",
      "status":1
    },
    "relationships": {
      "target_type": {
        "data": { "type": "taxonomy_term--subscription_target_type", "id": "18926ba9-4a93-429d-ae63-27836af5d366" }
      }
    }
  }
}

1.3.1.Subscription API 更新单个数据的请求参数

具体的字段如下: 参数名 类型 是否必需 描述
type string 是 bundle可设置subscription
title string 否 标题
target_type int 是 订阅类型分类
action string 是 默认值like,collection, follow, comment,post, update,subscribe
target_id string 是 订阅栏目id

1.4. 删除单个数据

DELETE /portal/api/v2/subscription/{bundle}/{8beb578b-7557-4656-90e8-0f12395e35a2} HTTP/1.1
Host: etl.dd:8083
Accept: application/vnd.api+json
Authorization: Bearer 49353835a83f30b26f81dc2351330a4b

1.5. 查询单个数据

GET /portal/api/v2/subscription/{bundle}/{d1f94da3-990d-4d70-9441-a30bbed4d91e} HTTP/1.1
Host: etl.dd:8083
Authorization: Bearer 49353835a83f30b26f81dc2351330a4b
Accept: application/vnd.api+json

1.6.查询当前用户自己创建的所有数据

GET /portal/api/v2/subscription/me?_format=hal_json HTTP/1.1
Host: portal.xx.edu.com.cn
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j

action={like}&type={subscription}&target_type={7}&page={}&items_per_page={}

1.7.查询系统默认订阅列表

GET /portal/api/v2/subscription/default?_format=hal_json HTTP/1.1
Host: portal.xx.edu.com.cn
Authorization: Bearer 39aec9c68b679d43de6803e0f14c223j

action={like}&type={subscription}&target_type={7}&page={}&items_per_page={}

1.8.查询数据的请求参数说明

具体的字段如下: 参数名 类型 是否必需 描述
type string 是 bundle可设置subscription
title string 否 标题
target_type int 是 订阅类型分类
action string 是 默认值like,collection, follow, comment,post, update,subscribe
target_id string 是 订阅栏目id

1.9. 查询数据的响应信息

[
   {
      "id":"5",
      "uuid":"39aec9c68b679d43de6803e0f14c223j",
      "target_id":"testt",
      "title":"新闻动态",
      "target_type":"7",
      "action":"follow",
      "type":"subscription",
      "created":"2020-05-14T10:20:14+0800"
   },
   {
      "id":"4",
      "uuid":"39aec9c68b679d43de6803e0f14c223f",
      "target_id":"changed0000",
      "title":"通知公告",
      "target_type":"2",
      "action":"like",
      "type":"subscription",
      "created":"2020-05-12T15:36:42+0800"
   },
   {
      "id":"2",
      "uuid":"39aec9c68b679d43de6803e0f14c223w",
      "target_id":"changed0000",
      "title":"会议通知",
      "target_type":"1",
      "action":"follow",
      "type":"subscription",
      "created":"2020-05-12T15:08:21+0800"
      "enable":1 
   }
]

1.9.1.响应信息字段说明

具体的字段如下: 参数名 类型 描述
type string 订阅类型,用户订阅列表和系统默认订阅列表(system_subscription_list)
title string 标题
target_type int 订阅类型分类
action string 默认值like,collection, follow, comment,post, update,subscribe
target_id string 订阅栏目id
created date 创建时间
enable int 是否默认开启,1为开启,当查询系统默认订阅列表时可用。

1.10.错误码

融合门户REST API接口较多,开发者使用过程中不可避难会遇到各种问题,这里提供了常见的错误码释义。

错误码 含义
200 OK
201 Created
202 Accepted
204 No Content
301 Moved Permanently
302 Found
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
415 Unsupported Media Type
500 Internal Server Error
501 Not Implemented
Clone repository
  • Home
  • 数据管理手册
    • 094.Views twig 配置
    • ETL01.数据管理使用手册 V2.0
    • ETL02.Source 数据请求 data_fetcher_plugin
    • ETL03.Source 解析 data_parser_plugin
    • ETL04.Source 认证插件 authentication
    • ETL05.Porcess plugins 明细
    • ETL06.URL endpoint 数据管理E
    • ETL07.Mysql 数据管理
    • ETL08.MSSQL 数据管理
    • ETL09.Oracle 数据管理
    • ETL10.Token 列表
  • 门户V2 API 文档
    • 01.Portal Rest API v2
    • 01.Resource API
    • 02.App API
View All Pages