跳到主要内容

Post 脚本配置

Threads 更新\nThreads 现在支持纯文本发帖:content_type = 2。该值仅适用于 Threads;视频、图片和草稿能力保持不变。\n:::

本页面记录了任务创建中使用的 post 脚本的配置参数。

概述​

post 脚本用于自动发布内容(视频或图片)到 TikTok、Instagram 或 Threads。TikTok 和 Instagram 支持下文所述的平台专属发布方式和声音选项;Threads 支持带标题文案的媒体发布和草稿保存。

请求参数​

创建任务时,可以指定以下顶级参数:

参数类型必需默认值描述
serialsstring[]条件必需[]设备序列号列表(模式 1:基于设备)
usernamesstring[]条件必需[]用户名列表,直接为这些账号创建任务(模式 2:基于用户名)
script_namestring是-要执行的脚本名称(如 "post")
script_configobject是-脚本配置参数(见下文)
enable_multi_accountboolean否false启用多账号模式(为设备上的每个账号创建任务)
start_timestring否-可选的开始时间,格式为 "HH:MM"
platformstring条件必需*自动目标平台:tiktok、instagram、threads。见下方说明

注意: 必须提供 serials 或 usernames 其中之一。

*Platform 参数行为:

  • TikMatrix 和 IgMatrix:即使提供了 platform 参数也会被忽略。平台会根据应用名称自动确定(TikMatrix → tiktok,IgMatrix → instagram)。
  • TikMatrix Pro:platform 参数是必需的,必须明确指定为 tiktok、instagram 或 threads。
  • Threads:支持视频/图片发布、多图、标题文案、两种素材来源,以及 save_draft。因为 Threads 应用不提供这些 TikTok/Instagram 特有的流程,所以会忽略声音、商品链接、位置(placement)、封面、AI 标签、故事链接和原生定时发布等设置。

脚本配置 (script_config)​

script_config 对象包含发布脚本的参数。以下是可用参数:

通用参数(TikTok、Instagram 和 Threads)​

参数类型必需默认值描述
content_typeinteger否0内容类型:0 = 视频,1 = 图片
image_countinteger否1选择图片数量(当 content_type = 1 时)
captionsstring否""帖子标题文本。支持 spintax 格式:{选项1|选项2|选项3}
caption_formatstring否"multiline"多行标题的处理方式:multiline(插入真实换行符)或 singleline(将 \n 替换为空格)
ai_labelboolean否false是否为帖子添加 AI 生成内容标签
save_draftboolean否false将帖子保存为草稿而非立即发布
post_waystring否"addButton"发布方式。详情请参见下方的 发布方法 部分
material_sourcestring否"materialLibrary"素材来源:materialLibrary(素材库)或 localFolder(本地文件夹),如果提供了 material_list 则忽略此参数
material_pathstring条件必需""本地文件夹路径(当 material_source = "localFolder" 时必需)
material_liststring[]否[]直接传递素材文件路径数组。 提供此参数时,将跳过 material_source 和 material_path 的逻辑。推荐用于 API 自动化场景。
materials_tagsstring否""逗号分隔的素材标签,用于从素材库筛选
upload_wait_timeinteger否10等待上传完成的秒数
upload_wait_time_mininteger否-等待时间区间的下限。同时设置上下限时,脚本会为每个任务在该区间内随机取值
upload_wait_time_maxinteger否-等待时间区间的上限
sound_wait_timeinteger否10等待音频加载的秒数
sound_wait_time_mininteger否-等待时间区间的下限。同时设置上下限时,脚本会为每个任务在该区间内随机取值
sound_wait_time_maxinteger否-等待时间区间的上限
add_soundstring/integer否"-1"音频选项:-1 = 默认,0 = 禁用,1 = 启用,custom = 使用自定义音频
sound_namestring条件必需""音频名称/URL(当 post_way = "useSound" 时必需)
custom_sound_keywordstring条件必需""搜索自定义音频的关键词(当 add_sound = "custom" 时必需)
origin_sound_volumeinteger否100原始音频音量(0-100)
add_sound_volumeinteger否100添加音频音量(0-100)

upload_wait_time 同时适用于正常发布和 save_draft 草稿模式。即使保存为草稿,TikTok/Instagram 也仍然需要时间在后台完成视频上传。

upload_wait_time 和 sound_wait_time 也支持区间写法:传入 upload_wait_time_min / upload_wait_time_max(或 sound_wait_time_min / sound_wait_time_max),脚本会为每个任务在该区间内重新随机取值,避免所有任务都等待相同的秒数。上下限都存在时优先使用区间,否则使用单值字段。

发布方法(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 专属参数​

参数类型必需默认值描述
placementstring否""发布位置:""(普通视频,默认)或 "story"(TikTok Story)。设置为 "story" 时,脚本在音乐设置完成后点击"Your Story"直接发布,跳过标题输入、产品链接和 AI 标签步骤。
add_product_linkinteger否0是否添加商品/购物链接:0 = 否,1 = 是

Instagram 专属参数​

参数类型必需默认值描述
placementstring否"reel"发布位置:reel(Reels 短视频)、story(Stories 故事),或 post(常规信息流帖子)。注意: 当 placement 为 post 时,不支持音频选项
enable_schedule_reelsboolean否false是否将 Reel 安排在未来时间发布
schedule_reels_timestring条件必需""计划发布时间,格式为 YYYY-MM-DD HH:MM(当 enable_schedule_reels = true 时必需)
story_linkstring否""附加到 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
}
}

相关文档​