
# 普通卡片消息
#### 功能介绍
该接口用于向通知中心发送普通卡片通知。
#### 接口约束
- **认证方式：** access_token，请参考[获取access_token](https://open.welink.huaweicloud.com/docs/#/990hh0/ka0vzc/q76fsn)
原V1接口可以继续使用，但不推荐，文档不再体现。
- **权限申请：** 开发者在调用本接口前，需要到[开发者后台](https://open.welink.huaweicloud.com/wecode-site/index.html#/wecode/guide/guide)申请接口权限，申请流程请参考[接口权限申请](https://open.welink.huaweicloud.com/docs/#/990hh0/ka0vzc/r123qy?type=internal)
 
#### 调试
您可以在[API Explorer](https://open.welink.huaweicloud.com/apiexplorer/#/apiexplorer?type=internal&path=/messages/v2/card/common&method=POST)中调试该接口。
#### URL
POST https://open.welink.huaweicloud.com/api/messages/v2/card/common
#### 请求消息
**请求头部见表1**
表1请求头部
| **参数**              | **是否必选** | **参数类型** | **描述（值）**        |
|:---|:---|:---|:---|
| x-wlk-Authorization | 是        | String   | access_token     |
| Content-Type        | 是        | String   | application/json |
   
**请求参数见表2**
表2 请求参数
| **参数**            | **是否必选** | **参数类型**        | **说明**                                                                                                                                                                                                                 |
|:---|:---|:---|:---|
| msgOwner          | 是        | String          | 消息发送方，如"考勤"，长度不超过18字节。                                                                                                                                                                                                 |
| publicAccID       | 否        | String          | 接收消息的公众号ID，不传则默认发送消息到通知中心；可以在管理后台-公众号-公众号设置找到公众号ID                                                                                                                                                                     |
| msgRange          | 否        | String          | 0:按用户推送;1:按部门发送;2:按角色发送；默认0:按用户推送                                                                                                                                                                                      |
| toUserList        | 否        | Array\[String\] | 接收消息的人员ID（多个接收者用','分隔，最多支持1000个）；msgRange=0时必传                                                                                                                                                                         |
| departmentList    | 否        | Array\[String\] | 接收消息的部门ID（多个接收者用','分隔，最多支持100个）；msgRange=1时必传                                                                                                                                                                          |
| roleList          | 否        | Array\[String\] | 接收消息的角色ID（多个接收者用','分隔，最多支持100个）；msgRange=2时必传                                                                                                                                                                          |
| msgTitle          | 是        | String          | 消息标题，长度不超过128字节。 如仅展示中文消息，可直接传普通string，如 "出差电子流" 。 需要双语则参考请求包体示例，传入json类型的string。                                          |
| msgContent        | 是        | String          | 消息内容，长度不超过512字节。 如仅展示中文消息，可直接传普通string，如 "张三提交了一个去上海的出差申请" 。 需要双语则参考请求包体示例，传入json类型的string。                                 |
| receiveDeviceType | 否        | String          | 接收消息终端，0 ：PC；1 ：Mobile；2 ：PC+MOBILE（默认）                                                                                                                                                                                |
| urlType           | 否        | String          | 链接类型定义。当前只支持"html"，点击后跳转到相关链接                                                                                                                                                                                          |
| urlPath           | 否        | String          | 点击消息，跳转的链接                                                                                                                                                                                                             |
| desktopUrlPath    | 否        | String          | PC端消息跳转链接。 非必填，当receiveDeviceType配置为0和2时，需要配置该参数，如果不配置就默认使用urlPath                                                                                                         |
| messageStatus     | 否        | String          | 消息状态，具体显示见样例图片（PC端不支持，移动端从5.45.X版本开始支持）。 格式："messageStatus":"{"EN":"processed","CN":"已处理"}", 其中CN长度: 2-5个字; EN长度: 2-10个字符。 |
| statusColor       | 否        | String          | 状态对应的颜色（PC端支持7.0以上，移动端5.45 以上支持） 支持三种颜色1 (蓝色), 2（灰色）, 3（橙色）；默认：1                                                                                                          |
| isForceTips       | 否        | Integer         | 是否强提醒。 强提醒时PC WeLink收到消息，屏幕右下角会有弹窗提示。0：否；1：是。为空时默认为0，不强提醒                                                                                                               |
   
#### 响应消息
**正常返回结果：**
```
{
    "code":"0",
    "message":"ok",
    "itemId": "b376d37b-8998-40ec-8dec-2539fc981945"
}
```
**异常返回结果：**
```
{
    "code":"51019",
    "message":"不能给非粉丝用户推送消息",
    "failedUserId":["zhangsan@welink"]
}
```
#### 请求示例
- 请求参数示例
```
{
    "toUserList": ["john@welink", "zhangsan@welink"],
    "msgTitle": "{\"EN\": \"hello world\", \"CN\": \"你好\"}",
    "msgContent": "{\"CN\": \"欢迎使用\", \"EN\":\"Welcome\"}",
    "urlType": "html",
    "urlPath": "h5://demo.com",
    "msgOwner": "John"
}
```
- 请求URL示例
```
curl -X POST \
  'https://open.welink.huaweicloud.com/api/messages/v2/card/common' \
  -H 'Content-Type: application/json' \
  -H 'x-wlk-Authorization: access_token' \
  -d '{"请求参数 json格式"}'
```
#### 返回值
**返回参数说明：**
| **参数**       | **说明**                      |
|:---|:---|
| code         | 数据正常返回"0"，如果发生错误，会返回对应的错误码。 |
| message      | 返回信息，包括接口请求发生错误时的详细信息。      |
| itemId       | 消息ID。                       |
| failedUserId | 推送失败的用户ID                   |
   
#### 错误码
| **错误码** | **说明**                 |
|:---|:---|
| 51018   | 单次发送用户数最大1000人         |
| 51019   | 不能给非粉丝用户推送消息           |
| 51062   | 参数非法                   |
| 51078   | 系统异常                   |
| 51059   | msgRange参数类型值不支持       |
| 51056   | msgRange=1时，部门列表不能为空   |
| 51095   | msgRange=2时，角色列表不能为空   |
| 51104   | messageStatus消息状态参数不合法 |
   
#### 附录
**普通卡片样式：**
![](https://support.huaweicloud.com/devg-welink/figure/zh-cn_image_0000001485292045.png "点击放大")
