Slide 21
Slide 21 text
Sensitivity: Confidential
#h365ug
PowerShellで書くコードはこれだけ!
21
param
(
[Parameter(Mandatory=$false)]
[String] $param_location
)
$location_message = $param_location + "付近にな
りました"
$authKey = Get-AutomationVariable -Name
'fcmApiKey'
$location_message
$postText=@"
{
"to": "/topics/all",
"data": {
"url": "https://www.yahoo.jp"
},
"notification": {
"title": "$($location_message)",
"body": "近づきました"
}
}
"@
$postBody =
[Text.Encoding]::UTF8.GetBytes($postText)
$headers = @{
'Content-Type' = 'application/json'
'Authorization' = $authKey
}
$postText
$postBody =
[Text.Encoding]::UTF8.GetBytes($postText)
$postUri =
"https://fcm.googleapis.com/fcm/send"
$Response = Invoke-RestMethod -Method POST -
Headers $headers -Uri $postUri -Body $postBody
$Response