Skip to content

应用消息

消息推送

js
POST /v1/apps/mbox?access_token={access_token}&source_type={source_type}&for_all={for_all}

请求头部:

请求头说明
Content-Typeapplication/json

请求参数:

字段类型是否必填说明
access_tokenStringY访问令牌
source_typeStringN枚举,NATIVE/ISV,默认值为NATIVE,ISV应用时传ISV
typeStringY消息类型,default/text/iamge/file/article/template
for_allBooleanN是否全员推送,client_ids、usernames、scopes三者均为空,且for_all=true时,才全员推消息,否则均不生效
client_idsList<String>N消息推送的用户标识
scopesList<String>N发送范围,组织路径,例如/122/234/
usernamesList<String>N用户账号列表
platformsListN枚举,ANDROID/IOS/PC,默认值为IOS和ANDROID
bodyMapY推送消息体
body.at_allbooleanN是否AT所有人员
body.contentStringN发送内容,具体根据消息类型决定
body.is_gifintN是否gif图片,1代表是
body.sizeintN大小
body.widthintN图片宽度
body.heightintN图片高度
body.media_idStringN发送的媒体ID
body.pathStringN发送的媒体ID
body.file_statusintN文件状态,0为正常
body.nameStringN名称
body.articles.summaryStringN文章摘要
body.articles.cover_urlStringN封面URL 或 封面媒体Id
body.articles.cover_enabledbooleanN是否显示封面,true/false
body.articles.create_timelongN创建时间
body.articles.titleStringN文章标题
body.articles.urlStringN图文详情内容,有些获取url内容,为空时,图文详情显示content内容
body.template_idStringN模板ID,模板消息必填
body.dataStringN模板数据,模板消息必填,value为变量值,color为颜色,font_size为字号大小
body.emphasis_keywordStringN高亮属性,保留字段
body.top_colorStringN顶部颜色
body.top_avatarStringN顶部图标
body.top_titleStringN顶部标题
body.data.text_styleStringNnormal(正常)bold(粗体)
actionsJsonN消息按钮
第一层数据代表的多少行按钮[目前最多5个],
第二层数据代表一行有多少个按钮[目前最多5个]

参考按钮actions
action_aclJsonN按钮访问控制,参考按钮访问控制action_acl

请求示例:

js
/v1/apps/mbox?access_token=b646339e2f4f4234af6bae5f72db9879

文本示例:

点击查看文本示例
json
{
  "type": "TEXT", 
  "body": {
    "at_all": false, 
    "content": "2"
  }, 
  "client_ids": [
    "c24b6a94cfb14b79af12a1399edc9e31"
  ],
  "platforms": [
    "ANDROID","IOS","PC"
  ]
}

图片示例:

点击查看图片示例
json
{
  "type": "IMAGE", 
  "body": {
    "is_gif": 0, 
    "size": 1852, 
    "width": 280, 
    "media_id": "Z3JvdXAxL00wMC8wMC80OC9yQkFCR1ZkaFI5Q0FjNmp2QUFBSFBIRkhXSkk1NDEuanBn", 
    "content": "图片内容,base64编码", 
    "height": 280
  }, 
  "client_ids": [
    "c24b6a94cfb14b79af12a1399edc9e31"
  ],
  "platforms": [
    "ANDROID","IOS","PC"
  ]
}

文件示例:

点击查看文件示例
json
{
  "type": "FILE", 
  "body": {
    "file_status": 0, //文件状态,0代表正常
    "size": 71416, 
    "name": "IMG_0778.GIF", 
    "media_id": "Z3JvdXAxL00wMC8wMC80Ny9yQkFCR1ZkaEdBZUFYRkxmQUFFVy1JYmNRbTgwNjkuZ2lm", 
  }, 
  "client_ids": [
    "c24b6a94cfb14b79af12a1399edc9e31"
  ],
  "platforms": [
    "ANDROID","IOS","PC"
  ]
}

图文示例:

点击查看图文示例
json
{
  "type": "ARTICLE", 
  "body": {
    "articles": [
      {
        "summary": "", 
        "show_cover": false, 
        "cover_url": "Z3JvdXAxL00wMC8wMC8zQi9yQkFCR1ZkVlFwYUFicjJ3QUFQa2NkSHlFM280MDMuanBn", 
        "create_time": 1465205632846, 
        "author": "凯里",  
        "title": "云南丽江", 
        "content": "<p>这个文章被删除了</p>", 
        "url": ""
      }
    ]
  }, 
  "platforms": [
    "ANDROID", 
    "IOS", 
    "PC"
  ]
}

模板消息--根据模板ID:

点击查看模板消息示例
json
{
  "type": "TEMPLATE", 
  "body": {
    "template_id": "152891af-1bec-4a18-8201-a58e08a7afad", 
    "top_color": "#00ff00",
    "top_avatar": "Z3JvdXAxL00wMC8wMC80MC9yQkFCR1ZkWDQ0ZUFRY21LQUFBZXVHZDBHS0U4MTkuanBn",
    "top_title": "流程大师",
    "data": [
      {
        "key": "keyword1", 
        "value": "339208499", 
        "color": "#00ff00", 
        "font_size": "12", 
        "text_style": "normal"
      }, 
      {
        "key": "keyword2", 
        "value": "2016年01月05日", 
        "color": "#00ff00", 
        "font_size": "12", 
        "text_style": "normal"
      }, 
      {
        "key": "keyword3", 
        "value": "830138013810", 
        "color": "#00ff00", 
        "font_size": "12", 
        "text_style": "normal"
      }, 
      {
        "key": "keyword4", 
        "value": "8310380131", 
        "color": "#00ff00", 
        "font_size": "12", 
        "text_style": "bold"
      }
    ],
    "emphasis_keyword": "keyword1.DATA"
  }, 
  "client_ids": [
    "a86e83a26be44eb59806901cc8be5d5c"
  ], 
  "platforms": [
    "ANDROID"
  ]
}

富文本消息示例:

请前往富文本消息页面查看详细说明。

返回数据:

字段类型说明
idString推送计划ID
material_idString推送的素材ID
app_idString推送者ID
expectsint目标推送数
failsint推送失败数
oksint成功推送数
scopesList<String>发送范围,组织路径,例如/122/234/
client_idsList<String>消息推送的对象标记

返回示例:

json
{
  "status": 0, 
  "message": "Everything is ok.", 
  "result": {
    "domain_id": "atwork", 
    "org_id": "a918d8a6-67e9-4e76-8503-baa73d3c6fd2", 
    "id": "f3b9250c-96d4-414b-be7f-308f2fdeca99", 
    "app_id": "92bc3faa-12bd-4afc-9962-01f2410f0bee", 
    "material_id": "52dec89a-04a0-4127-99b5-a3d136c638a4", 
    "expects": 0, 
    "fails": 0, 
    "oks": 0, 
    "create_time": 1485053077748, 
    "refresh_time": 0, 
    "expect_time": 1485054877748, 
    "scopes": [ ], 
    "client_ids": [
      "/232/301/c24b6a94cfb14b79af12a1399edc9e31"
    ]
  }
}

错误返回值:

statusmessage说明
10011token not found.访问令牌不存在
202012没有对应的雇员没有对应的雇员

错误返回值:

statusmessage说明
10011token not found.访问令牌不存在