【问题标题】:Push notification codelab Uncaught SyntaxError: Unexpected identifier in curl request推送通知 codelab Uncaught SyntaxError: Unexpected identifier in curl request
【发布时间】:2016-10-12 08:10:30
【问题描述】:

我正在关注这个教程https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/#send_a_request_from_the_command_line_for_fcm_to_push_a_message

当我这样做时

curl --header "Authorization: key=AIzaSyCQHb2t8c3N255bH_CVmGych5QcNntFxYg" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"APA91bE4RJ7_9m2eJ_zlg1F90bLjVX8ctVpCBN24ElAXF--4wS_nnxg4LzkbJWeTe-peMN_StmOaQTEoGeCCNZE5Mssux3T-KbfGRVmRWzeQZM8opfUyv7FVjI9iEfETHG3O7i1qkIb-\"]}"

我得到 Uncaught SyntaxError: Unexpected identifier

但是我按照教程中的方法做了所有事情。我把我的 api 密钥放在那里,我的发件人 ID 也在 manifest.json 中,我也把订阅端点 url 放在那里。这是端点endpoint: https://android.googleapis.com/gcm/send/cl72SS1zE50:APA91bE4RJ7_9m2eJ_zlg1F…peMN_StmOaQTEoGeCCNZE5Mssux3T-KbfGRVmRWzeQZM8opfUyv7FVjI9iEfETHG3O7i1qkIb-

那么为什么会出现这个错误,这是什么标识符?

【问题讨论】:

    标签: javascript curl google-cloud-messaging firebase-cloud-messaging chrome-gcm


    【解决方案1】:

    curl --header etc etc 是一个 shell 命令。您链接到的教程说 从您的终端,运行下面的 cURL 命令

    Uncaught SyntaxError: Unexpected identifier 是 JavaScript 错误消息。您似乎正试图在 JavaScript 程序中输入该代码(可能通过将其粘贴到浏览器的开发人员工具控制台或 Node.JS REPL 中)。

    您需要在 shell(例如 Bash 或 Windows Power Shell)上运行命令,而不是在 JS 程序中。

    【讨论】:

    • 我遇到了同样的错误,但只是在一个特定的链接上。很奇怪。 (通过外壳)
    猜你喜欢
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多