{"id":20749203,"url":"https://github.com/tharushaudana/fcm-send-with-oauth2-php","last_synced_at":"2026-04-01T23:39:57.604Z","repository":{"id":246514348,"uuid":"820997634","full_name":"tharushaudana/fcm-send-with-oauth2-php","owner":"tharushaudana","description":"This is the latest way to send FCM messages via REST API.","archived":false,"fork":false,"pushed_at":"2024-06-28T07:59:52.000Z","size":1029,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-27T23:42:37.951Z","etag":null,"topics":["cloud-messaging","fcm","fcm-messaging","fcm-push-notification","fcmpush","firebase","oauth2","php","rest-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tharushaudana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-27T15:43:37.000Z","updated_at":"2025-08-22T08:24:03.000Z","dependencies_parsed_at":"2024-06-28T12:13:51.492Z","dependency_job_id":"968016f3-a163-44c6-94fa-ccc5663f6022","html_url":"https://github.com/tharushaudana/fcm-send-with-oauth2-php","commit_stats":null,"previous_names":["tharushaudana/fcm-send-with-oauth2-php"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tharushaudana/fcm-send-with-oauth2-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharushaudana%2Ffcm-send-with-oauth2-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharushaudana%2Ffcm-send-with-oauth2-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharushaudana%2Ffcm-send-with-oauth2-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharushaudana%2Ffcm-send-with-oauth2-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tharushaudana","download_url":"https://codeload.github.com/tharushaudana/fcm-send-with-oauth2-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tharushaudana%2Ffcm-send-with-oauth2-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-messaging","fcm","fcm-messaging","fcm-push-notification","fcmpush","firebase","oauth2","php","rest-api"],"created_at":"2024-11-17T08:21:34.592Z","updated_at":"2026-04-01T23:39:57.587Z","avatar_url":"https://github.com/tharushaudana.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firebase Cloud Messaging via REST API using PHP\n\nThis repository contains a PHP script to send Firebase Cloud Messages (FCM) via the REST API. It includes both the generation of an OAuth2 access token using a Google service account key and the sending of FCM messages.\n\n## Instructions\n\n1. **Clone the Repository**\n\n   ```sh\n   git clone https://github.com/tharushaudana/fcm-send-with-oauth2-php.git\n   ```\n\n2. **Edit Service Account Key Path**\n\n   In `access_token.php`, replace the placeholder with the path to your Google service account key JSON file:\n\n   ```php\n   $creds = file_get_contents('path/to/your/service-account-key.json');\n   ```\n\n3. **Edit FCM Data**\n\n   In `index.php`, edit the FCM data to suit your needs. Change the `validate_only` parameter to `true` if you only want to validate the request without sending a message:\n\n   ```php\n   $firebase_data = [\n       'validate_only' =\u003e false,\n       'message' =\u003e [\n           'topic' =\u003e 'user_4',\n           'notification' =\u003e [\n               'title' =\u003e 'test title',\n               'body' =\u003e 'test body',\n           ],\n           'android' =\u003e [\n               'collapse_key' =\u003e 'type_a',\n           ],\n           'data' =\u003e [\n               'test' =\u003e 'test value'\n           ]\n       ]\n   ];\n   ```\n\n4. **Load `index.php` Using a Web Server**\n\n   Ensure you are running a web server, then load `index.php` to send the FCM message.\n\n## Generating and Downloading the Google Service Account Key\n\nThe screenshots below will help you create and download the Google service account key JSON for your Firebase project:\n\n- ![Screenshot 1](screenshots/01.png)\n- ![Screenshot 2](screenshots/02.png)\n- ![Screenshot 3](screenshots/03.png)\n\nI hope this helps you implement the latest FCM send method via the REST API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftharushaudana%2Ffcm-send-with-oauth2-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftharushaudana%2Ffcm-send-with-oauth2-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftharushaudana%2Ffcm-send-with-oauth2-php/lists"}