test-cloudfunc-name2.ps1 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Test cloud functions by actual name (not ID)
  2. $ct = "application/json"
  3. $appId = "ncloudmaster"
  4. # Test getApigInfo with X-Parse-Application-Id header
  5. Write-Host "=== getApigInfo (header auth) ===" -ForegroundColor Cyan
  6. try {
  7. $headers = @{ "X-Parse-Application-Id" = $appId; "Content-Type" = $ct }
  8. $body = '{"apigId":"Vo3ROWEvDy"}'
  9. $r = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/getApigInfo" -Method POST -Headers $headers -Body $body -TimeoutSec 15
  10. Write-Host "Status: $($r.StatusCode) Body: $($r.Content)" -ForegroundColor Green
  11. } catch {
  12. $code = ""; $body = ""
  13. if ($_.Exception.Response) {
  14. $code = [int]$_.Exception.Response.StatusCode
  15. try { $stream = $_.Exception.Response.GetResponseStream(); $reader = New-Object System.IO.StreamReader($stream); $body = $reader.ReadToEnd() } catch {}
  16. }
  17. Write-Host "Status: $code Body: $body" -ForegroundColor Yellow
  18. }
  19. Write-Host ""
  20. # Test getApigInfo with _ApplicationId in body
  21. Write-Host "=== getApigInfo (body auth) ===" -ForegroundColor Cyan
  22. try {
  23. $body = '{"_ApplicationId":"ncloudmaster","apigId":"Vo3ROWEvDy"}'
  24. $r2 = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/getApigInfo" -Method POST -ContentType $ct -Body $body -TimeoutSec 15
  25. Write-Host "Status: $($r2.StatusCode) Body: $($r2.Content)" -ForegroundColor Green
  26. } catch {
  27. $code = ""; $body = ""
  28. if ($_.Exception.Response) {
  29. $code = [int]$_.Exception.Response.StatusCode
  30. try { $stream = $_.Exception.Response.GetResponseStream(); $reader = New-Object System.IO.StreamReader($stream); $body = $reader.ReadToEnd() } catch {}
  31. }
  32. Write-Host "Status: $code Body: $body" -ForegroundColor Yellow
  33. }
  34. Write-Host ""
  35. # Test getApigAuth
  36. Write-Host "=== getApigAuth (header auth) ===" -ForegroundColor Cyan
  37. try {
  38. $headers = @{ "X-Parse-Application-Id" = $appId; "Content-Type" = $ct }
  39. $body = '{"userId":"nd7NOCmFiE","apigId":"Vo3ROWEvDy"}'
  40. $r3 = Invoke-WebRequest -Uri "https://server.fmode.cn/parse/functions/getApigAuth" -Method POST -Headers $headers -Body $body -TimeoutSec 15
  41. Write-Host "Status: $($r3.StatusCode) Body: $($r3.Content)" -ForegroundColor Green
  42. } catch {
  43. $code = ""; $body = ""
  44. if ($_.Exception.Response) {
  45. $code = [int]$_.Exception.Response.StatusCode
  46. try { $stream = $_.Exception.Response.GetResponseStream(); $reader = New-Object System.IO.StreamReader($stream); $body = $reader.ReadToEnd() } catch {}
  47. }
  48. Write-Host "Status: $code Body: $body" -ForegroundColor Yellow
  49. }