Skip to content

Instantly share code, notes, and snippets.

@l3acucm
Last active November 23, 2018 09:57
Show Gist options
  • Select an option

  • Save l3acucm/a2779fd614aa8c5f04aee832a667d90c to your computer and use it in GitHub Desktop.

Select an option

Save l3acucm/a2779fd614aa8c5f04aee832a667d90c to your computer and use it in GitHub Desktop.
Sends data-only-payloaded message to FCM topic
# coding: utf-8
import requests, json
API_KEY = ""
url = "https://fcm.googleapis.com/fcm/send"
body = {
"to": "/topics/ru",
"data": {
"title":"mytitle",
"detail":"huimarjovy",
}
}
headers = {"Content-Type":"application/json", "Authorization": f"key={API_KEY}"}
print(requests.post(url, data=json.dumps(body), headers=headers).content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment