【发布时间】:2015-06-20 12:43:18
【问题描述】:
我每天都在使用 PowerShell 运行一个 php 脚本。我似乎无法从Invoke-RestMethod 返回json。怎么实现?
这是我正在使用的代码:
$limit = 200;
for ($i=1; $i -le $limit; $i++)
{
Write-Host $i started of $limit
$Site = "http://example.com/updates"
$Info = Measure-Command{
$data = @{call_type = 'powershell'}
$resp = (Invoke-RestMethod -Method Post -URI $Site -Body $data -TimeoutSec 500).results
}
Write-Host resp - On $resp.date, $resp.num were downloaded
Write-Host $i took $Info.TotalSeconds s
Write-Host ---------------------------------------
}
PHP 脚本正在传回一个 json 字符串,例如:
{date: '2014-09-30', num: 127569}
【问题讨论】:
标签: json powershell powershell-2.0 psobject