【发布时间】:2019-07-06 15:07:55
【问题描述】:
我正在尝试使用 Invoke-RestMethod 将 curl 转换为 powershell 以进行单信号推送
用于一个信号的脚本:
curl --include \
--request POST \
--header "Content-Type: application/json; charset=utf-8" \
--header "Authorization: Basic YOUR_REST_API_KEY" \
--data-binary "{\"app_id\": \"YOUR_APP_ID\",
\"contents\": {\"en\": \"English Message\"},
\"included_segments\": [\"Subscribed Users\"]}" \
https://onesignal.com/api/v1/notifications
我已尝试使用以下示例,但没有成功。
$uri = "https://onesignal.com/api/v1/notifications"
$parameters = @{
app_id = 'YOUR_APP_ID'
contents = "en: English Message"
included_segments = 'Subscribed Users'
data = 'foo:bar'
}
$parameters | Invoke-RestMethod -Uri $uri -Method Post
我已经使用这个 powershell 脚本进行 pushover,效果很好,但现在我想转移到 onesignal,但我在使用 app_id 将消息转发给用户的情况下,在哪里/如何将 rest api 密钥放入其中时遇到了问题。
代码截取自:https://documentation.onesignal.com/v5.0/reference#section-example-code-create-notification
我希望有人可以帮助我解决这个问题。
问候
【问题讨论】:
标签: json powershell curl