[PowerShell] Microsoft Translator の API を使ってみよう

???????????????????????????????? image

???????????????????????????????????????????????????????????????????????????????????????????????Microsoft Translator ????????????????????????

Microsoft Translator
https://www.microsofttranslator.com/

Microsoft Translator | Web ??????????? (??????)
https://www.microsofttranslator.com/web/

????????????????????????????????????????????????????

?MT? Microsoft Translator ????https://blogs.technet.com/hirookun/archive/2010/04/23/3327736.aspx

????Microsoft Translator ??????? API ?????PowerShell ?????????????????

????????????????

Microsoft Translator | ??????????
https://www.microsofttranslator.com/dev/

???????AJAX, SOAP, HTTP ? API ?????????????????????? HTTP ???????????????????????? Get-Translation ?????????

function Get-Translation {
  param([parameter(ValueFromPipeline=$true)]
   [String] $text = "Hello World!")

  $w = new-object system.net.webclient
  $enc = [Text.Encoding]::GetEncoding("utf-8")
  $appid = "myappid"
  $from = "en"
  $to = "ja"
  $api = "https://api.microsofttranslator.com/V2/Http.svc/Translate"
  $url = "{0}?appid={1}&from={2}&to={3}&text={4}"
     -f $api, $appid, $from, $to, $text
  $h = $enc.GetString($w.DownloadData($url))
  ([xml]$h).string.get_Innertext()
}

???????????????????????????????????????????????? "Hello World!" ??????????(??????????????)

PS> Get-Translation
???????!

PS> Get-Translation "Microsoft has built an application that combines the grassroots appeal of the town hall meeting with the reach of the Web."

Microsoft ?????????????????? Web ???????????????????????????

?????????! ?????????????????????????????????????????????????????????????????

PS> (Get-EventLog system -newest 1 -source "forefront endpoint protection").Message

A statement of health (SoH) request was sent, but there was no response from the server. The fo
llowing information is contained in the correlation ID:
GUID = {xxxxx}
Time stamp = 2010?4?23? 14:28:49

?? Get-Translation ??????????????

PS> (Get-EventLog system -newest 1 -source "forefront endpoint protection").Message | Get-Translation

??????? (SoH) ??????????????????????????? ???????? ID ?????????
GUID = {xxxxx}
??????? 2010?4?23? 14:28:49 =

?????????????????????????????????????????????????????????????????????????

?????????????????????Microsoft Translater ??? API ????Translate Method ??????????????????????????????????AppID ? Bing ??????????????? ID ????????????????????

Bing Developer Center
https://www.bing.com/developers/appids.aspx

Translate ??????????? XML ?????????????????????????????????

????????????????????????????????SOAP ????????????????????????????????????????????????????

??????????TextToSpeech ??????? API ??????????????????????????????????????????????