Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Can not make it work with latest Server key (long one) #6

Open
fanysoft opened this issue Apr 25, 2018 · 3 comments
Open

Can not make it work with latest Server key (long one) #6

fanysoft opened this issue Apr 25, 2018 · 3 comments

Comments

@fanysoft
Copy link

fanysoft commented Apr 25, 2018

Looks like this project does not work anymore with new FCM server key.

Running at PHP 7 and fixing incorrect "?>" in one of scripts I was finally getting some output from service.php like below.

As for service.php variable 'api_key' - looks like FCM is expecting new "Server key" (like AAAAfJORI48:APA91...), not "Legacy server key" (like AIzaSyDX..) from its console - Cloud messaging. With new key I have no output at all.

With old key I got error
=== Connecting to fcm-xmpp.googleapis.com:5235... === 07:33:32 === === Sent 129 bytes === 07:33:32 === === Read 152 bytes === 07:33:32 === === Read 197 bytes === 07:33:32 === X-OAUTH2X-GOOGLE-TOKENPLAIN === Sent 169 bytes === 07:33:32 === ADUzNTA1MTcwNzI3OUBnY20uZ29vZ2xlYXBpcy5jb20AQUl6YVN5QzFNOHJUa2tMVnBYb0NPT055bklodmJr === Read 194 bytes === 07:33:32 === Received BROWSER API key. Only SERVER API keys are accepted. === Read 16 bytes === 07:33:32

I got in touch with FB support and got reply:
Based off the error, looks like you're using the wrong key. You should be using the FCM server key. This can be found in the Firebase Console under the Project Settings -> Cloud Messaging.

see details at https://stackoverflow.com/questions/50004547/firebase-cloud-messaging-returns-received-browser-api-key-only-server-api-keys

@baudev
Copy link

baudev commented Jun 17, 2018

Why are you trying to use the Legacy Key? You should use the Server Key (which is on your screen by the way).

@fanysoft
Copy link
Author

fanysoft commented Jun 20, 2018

@baudev I tried to use all of them, without luck, php log shows error
PHP Notice: Undefined property: stdClass::$data in /Applications/MAMP/htdocs/stream.php on line 167

@baudev
Copy link

baudev commented Jun 21, 2018

I got a lot of errors too with this script. So, I've forked this project and improved it. You can found it there: https://github.com/baudev/Firebase-Cloud-Messaging-FCM-XMPP
I you still get some problems, create an issue over there 😉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants