跳到主要内容

收藏脚本配置

本页面介绍创建任务时 favorite 脚本的配置参数。

概述

favorite 脚本用于将帖子添加到 收藏夹(TikTok)/ 已保存(Instagram)。通过 API 提供多个目标帖子 URL 时,系统会为每个 URL 创建一个任务。使用 start_time 参数来控制任务的执行时间。

已收藏的帖子会被跳过

脚本会检测已收藏/已保存的帖子并跳过,因此重复执行任务不会将帖子取消收藏。

脚本配置 (script_config)

收藏脚本的配置参数如下:

参数

参数类型必需默认值描述
target_post_urlsstring[]Yes*[]要收藏的目标帖子 URL 数组(每个 URL 一个任务)
target_post_urlstringYes*""单个目标帖子 URL,或多个 URL 以换行/逗号分隔
备注

必须提供 target_post_urls 数组或 target_post_url 字符串。如果两者都提供,target_post_urls 优先。

任务创建说明

当提供多个目标帖子 URL 时,API 会为每个 URL 创建一个任务。例如,3 个 URL + 2 个设备 = 6 个任务。使用 start_time 参数来控制任务的开始时间。

示例

收藏单个帖子

curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "favorite",
"script_config": {
"target_post_url": "https://www.tiktok.com/@username/video/1234567890"
}
}'

收藏多个帖子

收藏多个帖子时,每个帖子创建一个任务:

curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "favorite",
"script_config": {
"target_post_urls": [
"https://www.tiktok.com/@user1/video/111",
"https://www.tiktok.com/@user2/video/222",
"https://www.tiktok.com/@user3/video/333"
]
}
}'

这将创建 3 个独立的任务,立即执行。

调度收藏任务

curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "favorite",
"script_config": {
"target_post_url": "https://www.tiktok.com/@username/video/1234567890"
},
"start_time": "14:30"
}'

通过用户名列表模式收藏

直接为特定账号创建收藏任务:

curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"usernames": ["@my_account1", "@my_account2"],
"script_name": "favorite",
"script_config": {
"target_post_url": "https://www.tiktok.com/@target/video/123"
}
}'

Instagram 保存示例

在 Instagram 上,favorite 脚本用于保存帖子(书签):

curl -X POST http://localhost:50809/api/v1/task \
-H "Content-Type: application/json" \
-d '{
"serials": ["device_serial_1"],
"script_name": "favorite",
"script_config": {
"target_post_url": "https://www.instagram.com/p/ABC123/"
}
}'

响应

{
"code": 0,
"message": "success",
"data": {
"task_ids": [601, 602, 603],
"created_count": 3
}
}

帖子 URL 格式

TikTok

https://www.tiktok.com/@username/video/1234567890123456
https://vm.tiktok.com/ABCDEFG/

Instagram

https://www.instagram.com/p/ABCDEFGHIJK/
https://www.instagram.com/reel/ABCDEFGHIJK/

最佳实践

  1. 调度任务:使用 start_time 参数将收藏操作分散在一段时间内执行,降低触发频率限制的风险。

  2. 使用多账号模式:启用 enable_multi_account 以在同一设备上使用多个账号收藏帖子。

错误代码

CodeDescription
40001目标帖子 URL 缺失
40003API 不支持该脚本
40301API 访问需要 Pro+ 套餐

另请参阅