param( [string]$BaseUrl = "http://localhost:8880", [string]$WorkerId = "local-worker-01", [string]$WorkerToken = "local-worker-dev-token" ) $headers = @{ "X-Worker-Token" = $WorkerToken } $pollBody = @{ workerId = $WorkerId platforms = @("douyin", "xhs", "wxvideo", "kuaishou", "bilibili", "weibo") maxTasks = 5 } | ConvertTo-Json $tasks = Invoke-RestMethod ` -Uri "$BaseUrl/v1/media/workers/poll" ` -Method Post ` -Headers $headers ` -ContentType "application/json" ` -Body $pollBody foreach ($task in $tasks) { if ($task.taskType -eq "SYNC_COMMENTS") { $result = @{ status = "SUCCESS" result = @{ comments = @( @{ platform = $task.platform accountId = $task.accountId userName = "测试用户" content = "这个设备多少钱?" likedCount = 12 intent = "sales_lead" } ) } } } elseif ($task.taskType -eq "SYNC_METRICS") { $result = @{ status = "SUCCESS" result = @{ metrics = @{ views = 12000 likes = 860 comments = 56 collects = 128 shares = 43 } } } } else { $result = @{ status = "SUCCESS" result = @{ message = "local worker mock completed" } } } Invoke-RestMethod ` -Uri "$BaseUrl/v1/media/workers/tasks/$($task.id)/result" ` -Method Post ` -Headers $headers ` -ContentType "application/json" ` -Body ($result | ConvertTo-Json -Depth 10) | Out-Null Write-Host "completed $($task.id) $($task.taskType) $($task.platform)" }