添加多设备怎么在分机上运行脚本

HAMI_0674813103 · 4 小时前

回答

Hamibot AI
1
· 4 小时前

要在Hamibot中添加多设备并在这些设备上运行脚本,你需要按照以下步骤操作:

  1. 获取设备ID

    • 在每台安装了Hamibot应用的设备上,进入应用设置
    • 找到"设备管理"或"设备信息"选项
    • 记录每台设备的唯一ID(类似a51d237e9af41ecc021c9ff6的字符串)和设备名称
  2. 通过API在多设备上运行脚本
    在API请求中,将多个设备信息添加到devices数组中:

// 文档地址 https://docs.hamibot.com/
http.request('https://api.hamibot.com/v1/scripts/你的脚本_id/run', {
  method: 'POST',
  contentType: 'application/json',
  headers: {
    authorization: 'hmp_xxxxxxxxxxxxxxx',
  },
  body: JSON.stringify({
    devices: [
      { _id: 'a51d237e9af41ecc021c9ff6', name: '设备1' },
      { _id: 'b7c8d9e0f1a2b3c4d5e6f7a8', name: '设备2' },
      { _id: 'c9d0e1f2a3b4c5d6e7f8a9b0', name: '设备3' }
    ],
  }),
});
  1. 使用curl命令示例
curl -X POST \
  -H "Authorization: hmp_xxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "devices": [
      {"_id": "a51d237e9af41ecc021c9ff6", "name": "设备1"},
      {"_id": "b7c8d9e0f1a2b3c4d5e6f7a8", "name": "设备2"},
      {"_id": "c9d0e1f2a3b4c5d6e7f8a9b0", "name": "设备3"}
    ]
  }' \
  https://api.hamibot.com/v1/scripts/你的脚本_id/run

注意:

  • 确保所有设备都已登录同一个Hamibot账号
  • 替换示例中的脚本_id为你的实际脚本ID
  • 替换hmp_xxxxxxxxxxxxxxx为你的实际API令牌
  • devices数组中可以添加任意数量的设备,最多支持你账号允许的设备上限

如果你想停止在特定设备上运行的脚本,可以使用DELETE方法,并在请求中指定相同的设备列表。

ℹ️ 本回答由 AI 生成,内容仅供参考