| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- # Test auth signing and relay via both endpoints
- $appKey = "ZmNmOGRhNjYzZTAx"
- $appSecretB64 = "ZWFhMTIxNTRjMjQ4Y2FkOTE1OWE5ZDZlYThiZWRmNDY="
- $appSecret = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($appSecretB64))
- Write-Host "appKey: $appKey"
- Write-Host "appSecret (decoded): $appSecret"
- $timestamp = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds().ToString()
- $signStr = "$timestamp#$appSecret"
- Write-Host "signStr: $signStr"
- $md5 = [System.Security.Cryptography.MD5]::Create()
- $signBytes = $md5.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($signStr))
- $sign = ($signBytes | ForEach-Object { $_.ToString("x2") }) -join ''
- Write-Host "sign: $sign"
- Write-Host ""
- # Test 1: Direct call to kuaizi API (bypass relay)
- Write-Host "=== Test 1: Direct kuaizi API call ===" -ForegroundColor Cyan
- $headers1 = @{
- "Content-Type" = "application/json"
- "APP-KEY" = $appKey
- "AUTH-TIMESTAMP" = $timestamp
- "AUTH-SIGN" = $sign
- }
- $directBody = @{
- account_id = "12859_117409"
- } | ConvertTo-Json -Compress
- try {
- # Try a lightweight endpoint to check auth - /v2/video/vlog/list
- $r1 = Invoke-RestMethod -Uri "https://openapi.kuaizi.co/v2/video/vlog/list" -Method POST -Headers $headers1 -Body $directBody -TimeoutSec 15
- Write-Host "openapi.kuaizi.co Response:" -ForegroundColor Green
- $r1 | ConvertTo-Json -Depth 3
- } catch {
- Write-Host "openapi.kuaizi.co Error: $($_.Exception.Message)" -ForegroundColor Red
- }
- Write-Host ""
- # Try open.kuaizi.co instead
- try {
- $r1b = Invoke-RestMethod -Uri "https://open.kuaizi.co/v2/video/vlog/list" -Method POST -Headers $headers1 -Body $directBody -TimeoutSec 15
- Write-Host "open.kuaizi.co Response:" -ForegroundColor Green
- $r1b | ConvertTo-Json -Depth 3
- } catch {
- Write-Host "open.kuaizi.co Error: $($_.Exception.Message)" -ForegroundColor Red
- }
- Write-Host ""
- # Test 2: Via Parse cloud function with relay
- Write-Host "=== Test 2: Relay via Parse function ===" -ForegroundColor Cyan
- $relayData = @{
- apiPath = "/v2/video/vlog/list"
- apiBody = @{ account_id = "12859_117409" }
- appKey = $appKey
- timestamp = $timestamp
- sign = $sign
- } | ConvertTo-Json -Depth 3 -Compress
- $parseBody = @{
- id = "sWvRr8RvPT"
- _ApplicationId = "ncloudmaster"
- action = "relay"
- relayData = $relayData
- } | ConvertTo-Json -Compress
- try {
- $r2 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/functions" -Method POST -ContentType "application/json" -Body $parseBody -TimeoutSec 15
- Write-Host "Parse relay Response:" -ForegroundColor Green
- $r2 | ConvertTo-Json -Depth 3
- } catch {
- Write-Host "Parse relay Error: $($_.Exception.Message)" -ForegroundColor Red
- }
|