我们使用 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/