php - Chrome 403 禁止错误的 GCM

标签 php javascript google-chrome google-chrome-extension google-cloud-messaging

我们使用 gcm 为 chrome 制作 chrome 扩展。我们获得像“ya29.**”这样的 Oauth,并将此扩展用于开发仪表板。

我们的服务器请求向 gcm 发送消息并收到此错误。

为什么 gcm for chrome 会返回此错误?

{
"error": {
    "errors": [
        {
            "domain": "gcmForChrome.message",
            "reason": "forbiddenForNonAppOwner",
            "message": "A message can only be sent by the owner of the app."
        }
    ],
    "code": 403,
    "message": "A message can only be sent by the owner of the app."
}

我们的服务器请求是这样的

curl_setopt($ch, CURLOPT_URL,'https://www.googleapis.com/gcm_for_chrome/v1/messages');
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($arr));

谢谢。

最佳答案

发布扩展了吗?它必须先发布(您可以发布给受信任的测试人员),然后才能发送推送消息。将其上传到开发人员仪表板是不够的。

还要确保 Chrome 网上应用店和您计算机上的扩展程序 ID 一致 ( https://developer.chrome.com/extensions/cloudMessaging.html#test-cloud )。

关于php - Chrome 403 禁止错误的 GCM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17774602/

相关文章:

javascript - 表中的删除按钮,jQuery

javascript - 通过 jquery 修改 HTML 字符串并生成另一个反射(reflect)所做更改的 html 字符串?

javascript - Ajax.ActionLink AjaxOptions 回调问题 (ASP.NET MVC 3)

google-chrome - Chrome 扩展 - 使用文件系统 API

php - 文件/图像复制

php - 类PHP中的奇怪错误对象

python - 通过 Google Chrome 以 headless 模式下载文件

google-chrome - chrome - 从 jks keystore 导入后 ssl 证书不显示

php - {"error":true ,"error_msg" :"Unknown error occurred in registration!"} during execution. .!

php - DB2如何使用PDO指定连接字符集