申请发布应用
通过订阅该事件,可接收应用提交发布申请事件
事件
| 项目 | 值 |
|---|---|
| 事件类型 | application.application.app_version.publish_apply_v6 |
| 支持的应用类型 | custom |
| 权限要求 订阅该事件所需的权限,开启其中任意一项权限即可订阅 | application:application.app_version:readonly 获取应用版本信息 |
| 字段权限要求 | > Tip: 该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请 contact:user.employee_id:readonly 获取用户 user ID |
| 推送方式 | Webhook |
事件体
| 名称 | 类型 | 描述 |
|---|---|---|
schema | string | 事件模式 |
header | event_header | 事件头 |
└ event_id | string | 事件 ID |
└ event_type | string | 事件类型 |
└ create_time | string | 事件创建时间戳(单位:毫秒) |
└ token | string | 事件 Token |
└ app_id | string | 应用 ID |
└ tenant_key | string | 租户 Key |
event | \- | - |
└ operator_id | user_id | 用户 ID |
└ union_id | string | 用户的 union id |
└ user_id | string | 用户的 user id 字段权限要求: contact:user.employee_id:readonly 获取用户 user ID |
└ open_id | string | 用户的 open id |
└ online_version | application.app_version_event | 当前线上版本信息 |
└ app_id | string | 应用 id |
└ version | string | 开发者填入的应用版本 ID 数据校验规则: - 最小长度: 1 字符 |
└ version_id | string | 唯一标识应用版本的 ID |
└ app_name | string | 应用默认名称 数据校验规则: - 最小长度: 1 字符 |
└ avatar_url | string | 应用头像 url |
└ description | string | 应用默认描述 数据校验规则: - 最小长度: 1 字符 |
└ scopes | app_scope\[\] | 应用权限列表 |
└ scope | string | 应用权限 |
└ description | string | 应用权限的国际化描述 |
└ level | int | 权限等级描述 可选值有: - 1: 普通权限 - 2: 高级权限 - 3: 超敏感权限 - 0: 未知等级 |
└ token_types | string\[\] | 返回用户身份类型user、应用身份类型tenant。如果两种类型都支持,则同时返回两个。 可选值有: - tenant: 应用身份类型 - user: 用户身份类型数据校验规则: - 长度范围: 0 ~ 200 |
└ back_home_url | string | 后台主页地址 |
└ i18n | app_i18n_info\[\] | 应用的国际化信息列表 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 - zh_hk: 繁体中文(中国香港) - zh_tw: 繁体中文(中国台湾) - id_id: 印度尼西亚语 - ms_my: 马来语 - de_de: 德语 - es_es: 西班牙语 - fr_fr: 法语 - it_it: 意大利语 - pt_br: 葡萄牙语(巴西) - vi_vn: 越南语 - ru_ru: 俄语 - th_th: 泰语 - ko_kr: 韩语 |
└ name | string | 应用国际化名称 数据校验规则: - 最小长度: 1 字符 |
└ description | string | 应用国际化描述(副标题) 数据校验规则: - 最小长度: 1 字符 |
└ help_use | string | 国际化帮助文档链接 |
└ common_categories | string\[\] | 应用分类的国际化描述 数据校验规则: - 最大长度: 3 |
└ events | string\[\] | 应用已订阅开放平台事件列表 |
└ status | int | 版本状态 可选值有: - 0: 未知状态 - 1: 审核通过 - 2: 审核拒绝 - 3: 审核中 - 4: 未提交审核 |
└ create_time | string | 版本创建时间(单位:s) |
└ publish_time | string | 版本发布时间(单位:s) |
└ ability | app_ability | 当前版本下应用开启的能力 |
└ gadget | gadget | 小程序能力 |
└ enable_pc_mode | int | pc 支持的小程序模式,bit 位表示 可选值有: - 1: sidebar 模式 - 2: pc 模式 - 4: 主导航模式 |
└ schema_urls | string\[\] | schema url 列表 |
└ pc_use_mobile_pkg | boolean | pc 端是否使用小程序版本 |
└ pc_version | string | pc 的小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ mobile_version | string | 移动端小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ mobile_min_lark_version | string | 移动端兼容的最低飞书版本 数据校验规则: - 最小长度: 1 字符 |
└ pc_min_lark_version | string | pc 端兼容的最低飞书版本 数据校验规则: - 最小长度: 1 字符 |
└ web_app | web_app | 网页能力 |
└ pc_url | string | pc 端 url |
└ mobile_url | string | 移动端 url |
└ bot | bot | 机器人能力 |
└ card_request_url | string | 消息卡片回调地址 |
└ workplace_widgets | workplace_widget\[\] | 小组件能力 |
└ min_lark_version | string | 最低兼容飞书版本号 |
└ navigate | navigate | 主导航小程序 |
└ pc | navigate_meta | pc 端主导航信息 |
└ version | string | 主导航小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ image_url | string | 默认图片 url |
└ hover_image_url | string | 选中态图片 url |
└ mobile | navigate_meta | 移动端主导航信息 |
└ version | string | 主导航小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ image_url | string | 默认图片 url |
└ hover_image_url | string | 选中态图片 url |
└ cloud_doc | cloud_doc | 云文档应用 |
└ space_url | string | 云空间重定向 url |
└ i18n | cloud_doc_i18n_info\[\] | 国际化信息 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 |
└ name | string | 云文档国际化名称 |
└ read_description | string | 云文档国际化读权限说明 |
└ write_description | string | 云文档国际化写权限说明 |
└ icon_url | string | 图标链接 |
└ mode | int | 云文档支持模式 可选值有: - 0: 未知 - 1: 移动端 |
└ docs_blocks | docs_block\[\] | 云文档小组件 |
└ block_type_id | string | BlockTypeID |
└ i18n | block_i18n_info\[\] | block 的国际化信息 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 |
└ name | string | 名称 数据校验规则: - 最小长度: 1 字符 |
└ mobile_icon_url | string | 移动端 icon 链接 |
└ pc_icon_url | string | pc 端口 icon 链接 |
└ message_action | message_action | 消息快捷操作 |
└ pc_app_link | string | pc 端链接 |
└ mobile_app_link | string | 移动端链接 |
└ i18n | message_action_i18n_info\[\] | 国际化信息 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 |
└ name | string | 国际化名称 数据校验规则: - 最小长度: 1 字符 |
└ plus_menu | plus_menu | 加号菜单 |
└ pc_app_link | string | pc 端链接 |
└ mobile_app_link | string | 移动端链接 |
└ remark | app_version_remark_event | 跟随应用版本的信息 |
└ remark | string | 备注说明 |
└ update_remark | string | 更新说明 |
└ visibility | app_visibility_event | 可见性名单 |
└ is_all | boolean | 是否全员可见 |
└ visible_list | app_visible_list_event | 可见名单 |
└ open_ids | user_id\[\] | 可见性成员 id 列表 |
└ union_id | string | 用户的 union id |
└ user_id | string | 用户的 user id |
└ open_id | string | 用户的 open id |
└ department_ids | string\[\] | 可见性部门的 id 列表 |
└ invisible_list | app_visible_list_event | 不可见名单 |
└ open_ids | user_id\[\] | 可见性成员 id 列表 |
└ union_id | string | 用户的 union id |
└ user_id | string | 用户的 user id |
└ open_id | string | 用户的 open id |
└ department_ids | string\[\] | 可见性部门的 id 列表 |
└ under_audit_version | application.app_version_event | 当前在审核的版本信息 |
└ app_id | string | 应用 id |
└ version | string | 开发者填入的应用版本 ID 数据校验规则: - 最小长度: 1 字符 |
└ version_id | string | 唯一标识应用版本的 ID |
└ app_name | string | 应用默认名称 数据校验规则: - 最小长度: 1 字符 |
└ avatar_url | string | 应用头像 url |
└ description | string | 应用默认描述 数据校验规则: - 最小长度: 1 字符 |
└ scopes | app_scope\[\] | 应用权限列表 |
└ scope | string | 应用权限 |
└ description | string | 应用权限的国际化描述 |
└ level | int | 权限等级描述 可选值有: - 1: 普通权限 - 2: 高级权限 - 3: 超敏感权限 - 0: 未知等级 |
└ token_types | string\[\] | 返回用户身份类型user、应用身份类型tenant。如果两种类型都支持,则同时返回两个。 可选值有: - tenant: 应用身份类型 - user: 用户身份类型数据校验规则: - 长度范围: 0 ~ 200 |
└ back_home_url | string | 后台主页地址 |
└ i18n | app_i18n_info\[\] | 应用的国际化信息列表 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 - zh_hk: 繁体中文(中国香港) - zh_tw: 繁体中文(中国台湾) - id_id: 印度尼西亚语 - ms_my: 马来语 - de_de: 德语 - es_es: 西班牙语 - fr_fr: 法语 - it_it: 意大利语 - pt_br: 葡萄牙语(巴西) - vi_vn: 越南语 - ru_ru: 俄语 - th_th: 泰语 - ko_kr: 韩语 |
└ name | string | 应用国际化名称 数据校验规则: - 最小长度: 1 字符 |
└ description | string | 应用国际化描述(副标题) 数据校验规则: - 最小长度: 1 字符 |
└ help_use | string | 国际化帮助文档链接 |
└ common_categories | string\[\] | 应用分类的国际化描述 数据校验规则: - 最大长度: 3 |
└ events | string\[\] | 应用已订阅开放平台事件列表 |
└ status | int | 版本状态 可选值有: - 0: 未知状态 - 1: 审核通过 - 2: 审核拒绝 - 3: 审核中 - 4: 未提交审核 |
└ create_time | string | 版本创建时间(单位:s) |
└ publish_time | string | 版本发布时间(单位:s) |
└ ability | app_ability | 当前版本下应用开启的能力 |
└ gadget | gadget | 小程序能力 |
└ enable_pc_mode | int | pc 支持的小程序模式,bit 位表示 可选值有: - 1: sidebar 模式 - 2: pc 模式 - 4: 主导航模式 |
└ schema_urls | string\[\] | schema url 列表 |
└ pc_use_mobile_pkg | boolean | pc 端是否使用小程序版本 |
└ pc_version | string | pc 的小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ mobile_version | string | 移动端小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ mobile_min_lark_version | string | 移动端兼容的最低飞书版本 数据校验规则: - 最小长度: 1 字符 |
└ pc_min_lark_version | string | pc 端兼容的最低飞书版本 数据校验规则: - 最小长度: 1 字符 |
└ web_app | web_app | 网页能力 |
└ pc_url | string | pc 端 url |
└ mobile_url | string | 移动端 url |
└ bot | bot | 机器人能力 |
└ card_request_url | string | 消息卡片回调地址 |
└ workplace_widgets | workplace_widget\[\] | 小组件能力 |
└ min_lark_version | string | 最低兼容飞书版本号 |
└ navigate | navigate | 主导航小程序 |
└ pc | navigate_meta | pc 端主导航信息 |
└ version | string | 主导航小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ image_url | string | 默认图片 url |
└ hover_image_url | string | 选中态图片 url |
└ mobile | navigate_meta | 移动端主导航信息 |
└ version | string | 主导航小程序版本号 数据校验规则: - 最小长度: 1 字符 |
└ image_url | string | 默认图片 url |
└ hover_image_url | string | 选中态图片 url |
└ cloud_doc | cloud_doc | 云文档应用 |
└ space_url | string | 云空间重定向 url |
└ i18n | cloud_doc_i18n_info\[\] | 国际化信息 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 |
└ name | string | 云文档国际化名称 |
└ read_description | string | 云文档国际化读权限说明 |
└ write_description | string | 云文档国际化写权限说明 |
└ icon_url | string | 图标链接 |
└ mode | int | 云文档支持模式 可选值有: - 0: 未知 - 1: 移动端 |
└ docs_blocks | docs_block\[\] | 云文档小组件 |
└ block_type_id | string | BlockTypeID |
└ i18n | block_i18n_info\[\] | block 的国际化信息 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 |
└ name | string | 名称 数据校验规则: - 最小长度: 1 字符 |
└ mobile_icon_url | string | 移动端 icon 链接 |
└ pc_icon_url | string | pc 端口 icon 链接 |
└ message_action | message_action | 消息快捷操作 |
└ pc_app_link | string | pc 端链接 |
└ mobile_app_link | string | 移动端链接 |
└ i18n | message_action_i18n_info\[\] | 国际化信息 数据校验规则: - 最小长度: 1 |
└ i18n_key | string | 国际化语言的 key 可选值有: - zh_cn: 简体中文 - en_us: 英文 - ja_jp: 日文 |
└ name | string | 国际化名称 数据校验规则: - 最小长度: 1 字符 |
└ plus_menu | plus_menu | 加号菜单 |
└ pc_app_link | string | pc 端链接 |
└ mobile_app_link | string | 移动端链接 |
└ remark | app_version_remark_event | 跟随应用版本的信息 |
└ remark | string | 备注说明 |
└ update_remark | string | 更新说明 |
└ visibility | app_visibility_event | 可见性名单 |
└ is_all | boolean | 是否全员可见 |
└ visible_list | app_visible_list_event | 可见名单 |
└ open_ids | user_id\[\] | 可见性成员 id 列表 |
└ union_id | string | 用户的 union id |
└ user_id | string | 用户的 user id |
└ open_id | string | 用户的 open id |
└ department_ids | string\[\] | 可见性部门的 id 列表 |
└ invisible_list | app_visible_list_event | 不可见名单 |
└ open_ids | user_id\[\] | 可见性成员 id 列表 |
└ union_id | string | 用户的 union id |
└ user_id | string | 用户的 user id |
└ open_id | string | 用户的 open id |
└ department_ids | string\[\] | 可见性部门的 id 列表 |
└ app_status | int | 应用状态 可选值有: - 0: 停用状态 - 1: 启用状态 |
事件体示例
json
{
"schema": "2.0",
"header": {
"event_id": "5e3702a84e847582be8db7fb73283c02",
"event_type": "application.application.app_version.publish_apply_v6",
"create_time": "1608725989000",
"token": "rvaYgkND1GOiu5MM0E1rncYC6PLtF7JV",
"app_id": "cli_9f5343c580712544",
"tenant_key": "2ca1d211f64f6438"
},
"event": {
"operator_id": {
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
},
"online_version": {
"app_id": "cli_9f3ca975326b501b",
"version": "1.0.0",
"version_id": "oav_d317f090b7258ad0372aa53963cda70d",
"app_name": "应用名称",
"avatar_url": "https://www.example.com",
"description": "应用描述",
"scopes": [
{
"scope": "contact:user.base",
"description": "获取应用信息",
"level": 1,
"token_types": [
"user"
]
}
],
"back_home_url": "https://www.example.com",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "应用名称",
"description": "应用描述",
"help_use": "https://www.example.com"
}
],
"common_categories": [
"分析工具"
],
"events": [
"应用审核事件"
],
"status": 1,
"create_time": "1610462759",
"publish_time": "1610462759",
"ability": {
"gadget": {
"enable_pc_mode": 1,
"schema_urls": [
"*:*"
],
"pc_use_mobile_pkg": false,
"pc_version": "1.0.0",
"mobile_version": "1.0.0",
"mobile_min_lark_version": "2.0",
"pc_min_lark_version": "2.0"
},
"web_app": {
"pc_url": "https://www.example.com",
"mobile_url": "https://www.example.com"
},
"bot": {
"card_request_url": "https://www.example.com"
},
"workplace_widgets": [
{
"min_lark_version": "1.0.0"
}
],
"navigate": {
"pc": {
"version": "1.0.0",
"image_url": "https://www.example.com",
"hover_image_url": "https://www.example.com"
},
"mobile": {
"version": "1.0.0",
"image_url": "https://www.example.com",
"hover_image_url": "https://www.example.com"
}
},
"cloud_doc": {
"space_url": "https://www.example.com",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "名称",
"read_description": "读权限说明",
"write_description": "写权限说明"
}
],
"icon_url": "https://www.example.com",
"mode": 1
},
"docs_blocks": [
{
"block_type_id": "blk_4fb61568435880110854c1d0",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "名称"
}
],
"mobile_icon_url": "https://www.example.com",
"pc_icon_url": "https://www.example.com"
}
],
"message_action": {
"pc_app_link": "https://www.example.com",
"mobile_app_link": "https://www.example.com",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "名称"
}
]
},
"plus_menu": {
"pc_app_link": "https://www.example.com",
"mobile_app_link": "https://www.example.com"
}
},
"remark": {
"remark": "备注说明",
"update_remark": "更新说明",
"visibility": {
"is_all": false,
"visible_list": {
"open_ids": [
{
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
}
],
"department_ids": [
"od-ddee42c0f8a948a5e650341e2153243b"
]
},
"invisible_list": {
"open_ids": [
{
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
}
],
"department_ids": [
"od-ddee42c0f8a948a5e650341e2153243b"
]
}
}
}
},
"under_audit_version": {
"app_id": "cli_9f3ca975326b501b",
"version": "1.0.0",
"version_id": "oav_d317f090b7258ad0372aa53963cda70d",
"app_name": "应用名称",
"avatar_url": "https://www.example.com",
"description": "应用描述",
"scopes": [
{
"scope": "contact:user.base",
"description": "获取应用信息",
"level": 1,
"token_types": [
"user"
]
}
],
"back_home_url": "https://www.example.com",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "应用名称",
"description": "应用描述",
"help_use": "https://www.example.com"
}
],
"common_categories": [
"分析工具"
],
"events": [
"应用审核事件"
],
"status": 1,
"create_time": "1610462759",
"publish_time": "1610462759",
"ability": {
"gadget": {
"enable_pc_mode": 1,
"schema_urls": [
"*:*"
],
"pc_use_mobile_pkg": false,
"pc_version": "1.0.0",
"mobile_version": "1.0.0",
"mobile_min_lark_version": "2.0",
"pc_min_lark_version": "2.0"
},
"web_app": {
"pc_url": "https://www.example.com",
"mobile_url": "https://www.example.com"
},
"bot": {
"card_request_url": "https://www.example.com"
},
"workplace_widgets": [
{
"min_lark_version": "1.0.0"
}
],
"navigate": {
"pc": {
"version": "1.0.0",
"image_url": "https://www.example.com",
"hover_image_url": "https://www.example.com"
},
"mobile": {
"version": "1.0.0",
"image_url": "https://www.example.com",
"hover_image_url": "https://www.example.com"
}
},
"cloud_doc": {
"space_url": "https://www.example.com",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "名称",
"read_description": "读权限说明",
"write_description": "写权限说明"
}
],
"icon_url": "https://www.example.com",
"mode": 1
},
"docs_blocks": [
{
"block_type_id": "blk_4fb61568435880110854c1d0",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "名称"
}
],
"mobile_icon_url": "https://www.example.com",
"pc_icon_url": "https://www.example.com"
}
],
"message_action": {
"pc_app_link": "https://www.example.com",
"mobile_app_link": "https://www.example.com",
"i18n": [
{
"i18n_key": "zh_cn",
"name": "名称"
}
]
},
"plus_menu": {
"pc_app_link": "https://www.example.com",
"mobile_app_link": "https://www.example.com"
}
},
"remark": {
"remark": "备注说明",
"update_remark": "更新说明",
"visibility": {
"is_all": false,
"visible_list": {
"open_ids": [
{
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
}
],
"department_ids": [
"od-ddee42c0f8a948a5e650341e2153243b"
]
},
"invisible_list": {
"open_ids": [
{
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
}
],
"department_ids": [
"od-ddee42c0f8a948a5e650341e2153243b"
]
}
}
}
},
"app_status": 1
}
}事件订阅示例代码
订阅方式
长连接方式(推荐):无需发布到公网地址,在本地开发环境中即可接收事件回调,且无需处理加解密逻辑。 发送至开发者服务器:需要提供服务器公网地址。
package main
import (
"context"
"fmt"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
"github.com/larksuite/oapi-sdk-go/v3/service/application/v6"
larkws "github.com/larksuite/oapi-sdk-go/v3/ws"
)
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
// 注册事件 Register event
eventHandler := dispatcher.NewEventDispatcher("", "").
OnP2ApplicationAppVersionPublishApplyV6(func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionPublishApplyV6) error {
fmt.Printf("[ OnP2ApplicationAppVersionPublishApplyV6 access ], data: %s\n", larkcore.Prettify(event))
return nil
})
// 构建 client Build client
cli := larkws.NewClient("YOUR_APP_ID", "YOUR_APP_SECRET",
larkws.WithEventHandler(eventHandler),
larkws.WithLogLevel(larkcore.LogLevelDebug),
)
// 建立长连接 Establish persistent connection
err := cli.Start(context.Background())
if err != nil {
panic(err)
}
}# SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
import lark_oapi as lark
def do_p2_application_application_app_version_publish_apply_v6(data: lark.application.v6.P2ApplicationApplicationAppVersionPublishApplyV6) -> None:
print(f'[ do_p2_application_application_app_version_publish_apply_v6 access ], data: {lark.JSON.marshal(data, indent=4)}')
# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
.register_p2_application_application_app_version_publish_apply_v6(do_p2_application_application_app_version_publish_apply_v6) \
.build()
def main():
# 构建 client Build client
cli = lark.ws.Client("APP_ID", "APP_SECRET",
event_handler=event_handler, log_level=lark.LogLevel.DEBUG)
# 建立长连接 Establish persistent connection
cli.start()
if __name__ == "__main__":
main()package com.example.sample;
import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.application.ApplicationService;
import com.lark.oapi.service.application.v6.model.P2ApplicationAppVersionPublishApplyV6;
import com.lark.oapi.event.EventDispatcher;
import com.lark.oapi.ws.Client;
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
public class Sample {
// 注册事件 Register event
private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("", "")
.onP2ApplicationAppVersionPublishApplyV6(new ApplicationService.P2ApplicationAppVersionPublishApplyV6Handler() {
@Override
public void handle(P2ApplicationAppVersionPublishApplyV6 event) throws Exception {
System.out.printf("[ onP2ApplicationAppVersionPublishApplyV6 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
}
})
.build();
public static void main(String[] args) {
// 构建 client Build client
Client client = new Client.Builder("APP_ID", "APP_SECRET")
.eventHandler(EVENT_HANDLER)
.build();
// 建立长连接 Establish persistent connection
client.start();
}
}// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import * as Lark from '@larksuiteoapi/node-sdk';
const baseConfig = {
appId: 'APP_ID',
appSecret: 'APP_SECRET'
}
// 构建 client Build client
const wsClient = new Lark.WSClient(baseConfig);
// 建立长连接 Establish persistent connection
wsClient.start({
// 注册事件 Register event
eventDispatcher: new Lark.EventDispatcher({}).register({
'application.application.app_version.publish_apply_v6': async (data) => {
console.log(data);
}
})
});package main
import (
"context"
"fmt"
"net/http"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
"github.com/larksuite/oapi-sdk-go/v3/core/httpserverext"
larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
"github.com/larksuite/oapi-sdk-go/v3/service/application/v6"
)
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
// 注册事件 Register event
eventHandler := dispatcher.NewEventDispatcher("", "").
OnP2ApplicationAppVersionPublishApplyV6(func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionPublishApplyV6) error {
fmt.Printf("[ OnP2ApplicationAppVersionPublishApplyV6 access ], data: %s\n", larkcore.Prettify(event))
return nil
})
// 创建路由处理器 Create route handler
http.HandleFunc("/webhook/event", httpserverext.NewEventHandlerFunc(handler, larkevent.WithLogLevel(larkcore.LogLevelDebug)))
err := http.ListenAndServe(":7777", nil)
if err != nil {
panic(err)
}
}# SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
from flask import Flask
from lark_oapi.adapter.flask import *
import lark_oapi as lark
app = Flask(__name__)
def do_p2_application_application_app_version_publish_apply_v6(data: lark.application.v6.P2ApplicationApplicationAppVersionPublishApplyV6) -> None:
print(f'[ do_p2_application_application_app_version_publish_apply_v6 access ], data: {lark.JSON.marshal(data, indent=4)}')
# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
.register_p2_application_application_app_version_publish_apply_v6(do_p2_application_application_app_version_publish_apply_v6) \
.build()
# 创建路由处理器 Create route handler
@app.route("/webhook/event", methods=["POST"])
def event():
resp = event_handler.do(parse_req())
return parse_resp(resp)
if __name__ == "__main__":
app.run(port=7777)package com.lark.oapi.sample.event;
import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.application.ApplicationService;
import com.lark.oapi.service.application.v6.model.P2ApplicationAppVersionPublishApplyV6;
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
@RestController
public class EventController {
// 注册事件 Register event
private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("verificationToken", "encryptKey")
.onP2ApplicationAppVersionPublishApplyV6(new ApplicationService.P2ApplicationAppVersionPublishApplyV6Handler() {
@Override
public void handle(P2ApplicationAppVersionPublishApplyV6 event) throws Exception {
System.out.printf("[ onP2ApplicationAppVersionPublishApplyV6 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
}
})
.build();
// 注入 ServletAdapter 实例 Inject ServletAdapter instance
@Autowired
private ServletAdapter servletAdapter;
// 创建路由处理器 Create route handler
@RequestMapping("/webhook/event")
public void event(HttpServletRequest request, HttpServletResponse response)
throws Throwable {
// 回调扩展包提供的事件回调处理器 Callback handler provided by the extension package
servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
}
}// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import http from 'http';
import * as lark from '@larksuiteoapi/node-sdk';
// 注册事件 Register event
const eventDispatcher = new lark.EventDispatcher({
encryptKey: '',
verificationToken: '',
}).register({
'application.application.app_version.publish_apply_v6': async (data) => {
console.log(data);
return 'success';
},
});
const server = http.createServer();
// 创建路由处理器 Create route handler
server.on('request', lark.adaptDefault('/webhook/event', eventDispatcher));
server.listen(3000);