1

我正在使用 Java 从 google C2DM 迁移到 GCM。我在不使用 JSON 的情况下阅读了这篇文章 GCM Push Notification。即使在谷歌文档上,我也发现允许使用纯文本或 UTF-8 内容类型。我正在为浏览器应用程序使用 API 密钥,并且还尝试了 curl 命令。每次我收到与授权相关的响应代码 401。以下是我正在形成的 URL:

Collapse_key=0&Auth_Token=

> my api key for browser apps

&data.payload=

> meesage to be send

&registration_id=

> id of registered device

请问401响应码的原因和解决方法?

4

1 回答 1

0

HTTP status code 401 occurred when API key is not valid. For details check here.

You should send data as a json format. The format is shown below. It is explained in details here.

{
  "registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."],
  "data" : {
    ...
  },
}
于 2012-08-09T06:33:46.853 回答