找到一段PS代码, 但是参数没有找到?- function BDTranslate{
- param(
- [string]$q,
- [string]$from='zh',
- [string]$to='en'
-
- )
-
- $appid = "你的AppId"
- $sign = '你的App密码'
-
- $salt = Get-Random
- $signtoken = "{0}{1}{2}{3}" -f $appid,$q,$salt,$sign
- $signtoken = Get-Hash -string $signtoken -algorithm MD5
- $response = Invoke-RestMethod http://api.fanyi.baidu.com/api/trans/vip/translate -Method Post -Body @{
- q=$q
- from="zh"
- to="en"
- appid=$appid
- salt=$salt
- sign = $signtoken.ToLower()
- }
- $response
- }
-
- BDTranslate -q 'PowerShell中文博客'
复制代码
|