# Full flow test: create video -> poll results # Uses cover images from existing videos as test materials # --- Config --- $appKey = "ZmNmOGRhNjYzZTAx" $appSecretB64 = "ZWFhMTIxNTRjMjQ4Y2FkOTE1OWE5ZDZlYThiZWRmNDY=" $appSecret = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($appSecretB64)) $accountId = "12859_117409" $callbackUrl = "https://server.fmode.cn/api/functions/cut/onemerge" # --- Generate timestamp and sign --- $timestamp = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds().ToString() $signStr = "$timestamp#$appSecret" $md5 = [System.Security.Cryptography.MD5]::Create() $signBytes = $md5.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($signStr)) $sign = ($signBytes | ForEach-Object { $_.ToString("x2") }) -join '' Write-Host "Timestamp: $timestamp" Write-Host "Sign: $sign" Write-Host "" # --- Build materials (use existing cover images as test) --- $materials = @( @{ type = "pic"; value = "https://img.kuaizi.co/video/12859/12172925/749/1080x1920_5000_96/b65038bd93c1214e3ffb99e964379a8a.jpg" }, @{ type = "pic"; value = "https://img.kuaizi.co/video/12859/12172918/749/1080x1920_5000_96/71d10a2e42c548492410d3f1f466320b.jpg" }, @{ type = "pic"; value = "https://img.kuaizi.co/video/12859/12172872/749/1080x1920_5000_96/70f54baeb92a44d35f022b31068311dd.jpg" } ) $preId = $timestamp $apiBody = @{ account_id = $accountId callback_url = $callbackUrl material_list = $materials tags = "test,openclaw,skill" proportion = "9:16" video_duration = @{ min = 10; max = 15 } pre_id = $preId compose_number = 1 ai_voice = 1 ai_bgm = 1 ai_flower = 1 ai_subtitle = 0 original_voice = 0 } $relayData = @{ apiPath = "/v2/video/vlog/create" apiBody = $apiBody appKey = $appKey timestamp = $timestamp sign = $sign } | ConvertTo-Json -Depth 5 -Compress $requestBody = @{ action = "relay" relayData = $relayData } | ConvertTo-Json -Compress # --- Step 1: Create video --- Write-Host "=== Step 1: kuaizi-video-create ===" -ForegroundColor Cyan try { $r1 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/functions/cut/onemerge" -Method POST -ContentType "application/json" -Body $requestBody -TimeoutSec 30 Write-Host "Response:" -ForegroundColor Green $r1 | ConvertTo-Json -Depth 5 # Extract task_id $taskId = "" if ($r1.data -and $r1.data.task_id) { $taskId = $r1.data.task_id } elseif ($r1.task_id) { $taskId = $r1.task_id } if ($taskId) { Write-Host "" Write-Host "task_id: $taskId" -ForegroundColor Yellow # --- Step 2: Poll for results --- Write-Host "" Write-Host "=== Step 2: kuaizi-video-query (polling) ===" -ForegroundColor Cyan Write-Host "Polling every 15s, max 4 attempts for this test..." $pollBody = @{ id = "sWvRr8RvPT" _ApplicationId = "ncloudmaster" action = "query" taskId = $taskId } | ConvertTo-Json -Compress for ($i = 1; $i -le 4; $i++) { Write-Host " Poll #$i..." -NoNewline $r2 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/functions" -Method POST -ContentType "application/json" -Body $pollBody -TimeoutSec 15 $dataCount = 0 if ($r2.data) { $dataCount = $r2.data.Count } if ($dataCount -gt 0) { Write-Host " Got $dataCount video(s)!" -ForegroundColor Green $r2 | ConvertTo-Json -Depth 5 break } else { Write-Host " No results yet (still generating)" -ForegroundColor DarkYellow if ($i -lt 4) { Write-Host " Waiting 15s..." Start-Sleep -Seconds 15 } } } Write-Host "" Write-Host "Note: Video generation typically takes 2-5 min. Use taskId=$taskId to check later." -ForegroundColor Yellow } else { Write-Host "No task_id in response" -ForegroundColor Red } } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red if ($_.Exception.Response) { $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream()) Write-Host "Response body: $($reader.ReadToEnd())" -ForegroundColor Red } }