curl命令未使用pusher执行推送通知

问题描述

我正在使用ESP32开发Android应用程序。我想要一个系统,在该系统中,当我按下按钮(硬件按钮)时,它会向Android应用发送通知。我已将数据连接到Firebase,并使用推送程序发送了通知。我的设备已集成。但是,我无法执行推送通知curl命令。 当我执行curl命令时(我什至下载了curl.exe并设置路径):@H_404_1@

curl -H "Content-Type: application/json" \
 -H "Authorization: Bearer **Secret Key**" \
 -X POST "https://**Instance ID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" \
 -d '{"interests":["hello","fcm":{"notification":{"title":"Hello","body":"Hello,world!"}}}'

我在命令提示符中出现错误,如下所示:@H_404_1@

C:\Windows\system32>curl -H "Content-Type: application/json" \
curl: (6) Could not resolve host: \
C:\Windows\system32>     -H "Authorization: Bearer **Secret Key**" \
'-H' is not recognized as an internal or external command,operable program or batch file.
C:\Windows\system32>     -X POST "https://**Instance ID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" \
'-X' is not recognized as an internal or external command,operable program or batch file.
C:\Windows\system32>     -d '{"interests":["hello"],world!"}}}'
'-d' is not recognized as an internal or external command,operable program or batch file.

解决方法

整个块应该是一个命令,但是您的命令行似乎一次执行了一行。

尝试以下操作,我应该将其作为单行命令运行

curl -H "Content-Type: application/json" -H "Authorization: Bearer **Secret Key**"  -X POST "https://**InstanceID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" -d '{"interests":["hello","fcm":{"notification": "title":"Hello","body":"Hello,world!"}}}'