phpfirebasefirebase-cloud-messaging

How to use the FCM HTTP v1 API with php


I have used FCM with the legacy protocol but cannot find any concrete documentation to use the new FCM HTTP v1 API with php.

I have managed to import the Google API Client Library into my project but cannot find any documentation or tutorials on how to obtain the access token for the required scopes for fcm messages.


Solution

  • If you are willing to use an existing library instead of implementing it yourself, you might consider having a look at https://github.com/kreait/firebase-php/ which has received support for FCM just today.

    https://firebase-php.readthedocs.io/en/latest/cloud-messaging.html

    If it isn't for you, you will at least be able to extract the connections to the FCM REST API with PHP from the source code. In short, it's the implementation of https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages .