Post 脚本配置
本页面记录了任务创建中使用的 post 脚本的配置参数。
概述
post 脚本用于自动发布内容(视频或图片)到 TikTok 或 Instagram。它支持多种发布方式、素材来源和音频选项。
请求参数
创建任务时,可以指定以下顶级参数:
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|---|---|---|---|---|
| serials | string[] | 条件必需 | [] | 设备序列号列表(模式 1:基于设备) |
| usernames | string[] | 条件必需 | [] | 用户名列表,直接为这些账号创建任务(模式 2:基于用户名) |
| script_name | string | 是 | - | 要执行的脚本名称(如 "post") |
| script_config | object | 是 | - | 脚本配置参数(见下文) |
| enable_multi_account | boolean | 否 | false | 启用多账号模式(为设备上的每个账号创建任务) |
| start_time | string | 否 | - | 可选的开始时间,格式为 "HH:MM" |
| platform | string | 条件必需* | 自动 | 目标平台:tiktok、instagram。见下方说明 |
注意: 必须提供 serials 或 usernames 其中之一。
*Platform 参数行为:
- TikMatrix 和 IgMatrix:即使提供了
platform参数也会被忽略。平台会根据应用名称自动确定(TikMatrix → tiktok,IgMatrix → instagram)。 - TikMatrix Pro:
platform参数是必需的,必须明确指定为tiktok或instagram。
脚本配置 (script_config)
script_config 对象包含发布脚本的参数。以下是可用参数:
通用参数(TikTok 和 Instagram)
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|---|---|---|---|---|
| content_type | integer | 否 | 0 | 内容类型:0 = 视频,1 = 图片 |
| image_count | integer | 否 | 1 | 选择图片数量(当 content_type = 1 时) |
| captions | string | 否 | "" | 帖子标题文本。支持 spintax 格式:{选项1|选项2|选项3} |
| caption_format | string | 否 | "multiline" | 多行标题的处理方式:multiline(插入真实换行符)或 singleline(将 \n 替换为空格) |
| ai_label | boolean | 否 | false | 是否为帖子添加 AI 生成内容标签 |
| save_draft | boolean | 否 | false | 将帖子保存为草稿而非立即发布 |
| post_way | string | 否 | "addButton" | 发布方式。详情请参见下方的 发布方法 部分 |
| material_source | string | 否 | "materialLibrary" | 素材来源:materialLibrary(素材库)或 localFolder(本地文件夹),如果提供了 material_list 则忽略此参数 |
| material_path | string | 条件必需 | "" | 本地文件夹路径(当 material_source = "localFolder" 时必需) |
| material_list | string[] | 否 | [] | 直接传递素材文件路径数组。 提供此参数时,将跳过 material_source 和 material_path 的逻辑。推荐用于 API 自动化场景。 |
| materials_tags | string | 否 | "" | 逗号分隔的素材标签,用于从素材库筛选 |
| upload_wait_time | integer | 否 | 10 | 等待上传完成的秒数 |
upload_wait_time同时适用于正常发布和save_draft草稿模式。即使保存为草稿,TikTok/Instagram 也仍然需要时间在后台完成视频上传。 | sound_wait_time | integer | 否 | 10 | 等待音频加载的秒数 | | add_sound | string/integer | 否 | "-1" | 音频选项:-1= 默认,0= 禁用,1= 启用,custom= 使用自定义音频 | | sound_name | string | 条件必需 | "" | 音频名称/URL(当 post_way = "useSound" 时必需) | | custom_sound_keyword | string | 条件必需 | "" | 搜索自定义音频的关键词(当 add_sound = "custom" 时必需) | | origin_sound_volume | integer | 否 | 100 | 原始音频音量(0-100) | | add_sound_volume | integer | 否 | 100 | 添加音频音量(0-100) |
发布方法(post_way)
post_way 参数用于控制脚本如何打开发布界面:
| 值 | 说明 |
|---|---|
addButton | (默认) 点击应用内“+”创建按钮,然后从设备相册中选择媒体。适用于所有发布位置(reel、story、post)。推荐用于大多数场景。 |
share | 直接从媒体文件向 Instagram/TikTok 应用触发 Android 分享意图。这是一种绕过应用内导航的替代方法;当 addButton 流程在特定设备或应用版本上不稳定时很有用。 |
useSound | 先导航到特定音轨(通过 sound_name URL 或关键词),然后将视频附加到该音轨。仅适用于 Reels / TikTok。 需要设置 sound_name。与 placement = "post" 或 placement = "story" 不兼容。 |
当 placement 为 post(Instagram 信息流帖子)时,无论 post_way 为何,都不支持音频自动化。脚本会自动跳过音频步骤。
TikTok 专属参数
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|---|---|---|---|---|
| placement | string | 否 | "" | 发布位置:""(普通视频,默认)或 "story"(TikTok Story)。设置为 "story" 时,脚本在音乐设置完成后点击"Your Story"直接发布,跳过标题输入、产品链接和 AI 标签步骤。 |
| add_product_link | integer | 否 | 0 | 是否添加商品/购物链接:0 = 否,1 = 是 |
Instagram 专属参数
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|---|---|---|---|---|
| placement | string | 否 | "reel" | 发布位置:reel(Reels 短视频)、story(Stories 故事),或 post(常规信息流帖子)。注意: 当 placement 为 post 时,不支持音频选项 |
| enable_schedule_reels | boolean | 否 | false | 是否将 Reel 安排在未来时间发布 |
| schedule_reels_time | string | 条件必需 | "" | 计划发布时间,格式为 YYYY-MM-DD HH:MM(当 enable_schedule_reels = true 时必需) |
| story_link | string | 否 | "" | 附加到 Story 上的贴纸链接 URL(仅当 placement = "story" 时适用) |
示例
基础发布任务 - 直接传递素材路径
这是 API 自动化的推荐方式 - 直接传递素材文件路径,无需依赖素材库或文件夹扫描:
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"script_config": {
"content_type": 0,
"captions": "看看我的新视频!#热门 #推荐",
"material_list": [
"C:/Videos/video1.mp4"
],
"upload_wait_time": 60
}
}'
使用素材库发布(TikTok)
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1", "device_serial_2"],
"script_name": "post",
"script_config": {
"content_type": 0,
"captions": "看看我的新视频!#热门 #推荐",
"post_way": "addButton",
"material_source": "materialLibrary",
"materials_tags": "热门, 舞蹈",
"upload_wait_time": 60,
"add_sound": "-1"
},
"enable_multi_account": false
}'
TikTok Story 发布
直接发布到 TikTok Story。脚本完成音乐设置后点击"Your Story"——跳过标题/产品链接步骤:
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"script_config": {
"content_type": 0,
"placement": "story",
"post_way": "addButton",
"material_list": ["C:/Videos/story_video.mp4"],
"upload_wait_time": 30
}
}'
通过用户名列表创建发布任务
此模式允许您直接为特定账号创建任务,无需知道它们的设备序列号:
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"usernames": ["@user1", "@user2", "@user3"],
"script_name": "post",
"script_config": {
"content_type": 0,
"captions": "看看我的新视频!#热门 #推荐",
"material_list": [
"C:/Videos/video1.mp4"
],
"upload_wait_time": 60
}
}'
使用本地文件夹发布(Instagram)
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"script_config": {
"content_type": 0,
"captions": "精彩内容!#instagram #reels",
"post_way": "addButton",
"placement": "reel",
"material_source": "localFolder",
"material_path": "C:/Videos/instagram",
"upload_wait_time": 45
},
"enable_multi_account": true
}'
Instagram 信息流帖子 (placement: post)
发布到常规 Instagram 信息流(非 Reel)。此发布位置不支持音频选项:
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"platform": "instagram",
"script_config": {
"content_type": 0,
"captions": "New post! #instagram",
"placement": "post",
"post_way": "addButton",
"material_list": ["C:/Videos/my_video.mp4"],
"upload_wait_time": 45
}
}'
使用自定义音频发布
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"script_config": {
"content_type": 0,
"captions": "跟着这首热门音乐跳舞!",
"post_way": "addButton",
"add_sound": "custom",
"custom_sound_keyword": "热门舞曲 2024",
"origin_sound_volume": 30,
"add_sound_volume": 70,
"material_source": "materialLibrary",
"upload_wait_time": 60
}
}'
使用指定音频 URL 发布
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"script_config": {
"post_way": "useSound",
"sound_name": "https://www.tiktok.com/music/original-sound-7123456789",
"captions": "使用这个超棒的音乐!",
"material_source": "materialLibrary"
}
}'
发布图片(轮播图)
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"script_config": {
"content_type": 1,
"image_count": 5,
"captions": "看看这些照片!#图集",
"material_source": "localFolder",
"material_path": "C:/Images/carousel",
"upload_wait_time": 45
}
}'
显式指定平台发布
您可以使用 platform 参数显式指定目标平台。这在需要覆盖环境默认值时很有用:
curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "post",
"platform": "instagram",
"script_config": {
"content_type": 0,
"captions": "发布到 Instagram!#instagram #reels",
"placement": "reel",
"material_list": [
"C:/Videos/instagram_video.mp4"
],
"upload_wait_time": 60
}
}'
响应
{
"code": 0,
"message": "success",
"data": {
"task_ids": [101, 102],
"created_count": 2
}
}
相关文档
- 任务管理 API - 创建、列表和管理任务