|
|
@ -9,19 +9,16 @@ import datetime |
|
|
|
import json |
|
|
|
import sys |
|
|
|
|
|
|
|
# these below will only work for the browser that acquired the subscription info. You will need to extract those from our console OR the db. |
|
|
|
|
|
|
|
# https://fcm.googleapis.com/fcm/send/eqNQV7MVPic:APA91bGrIMxqz3sQ4wboUkmZithJHMAdrNgjm6BYcIGmgJozgEGeg23JsXLlNpnKwzBCmUXh1ciHmE_3wZakHX-Rho5f9Xovc28nun4nH7w4BMoYzX27pOw_pC4FtfAkBQaQ-8jm36jf |
|
|
|
# BDo2fIIN7qoA5bOVXdrHATZUSPHY7030V8PKW1mIHAZHDAxS-p6RggVeI7IZoi3bGxpR713RYY8H8vu-lX5LY1w |
|
|
|
# sVR_s8J4JHv3h4ZmvemL5w |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private_key_hex = "308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420ac868a9588a69ec9626db857caae42b0d654288abf73b0d8f1a6b43fff093508a1440342000466da453c1e793d7e21ab63b334e80f96715aa97e578639b5fe8092f8752fa6e1f9182324846c70bf1a3480411ba787e652be8049a36a14294681f745c4c4c4f7" |
|
|
|
# Subscription Info |
|
|
|
|
|
|
|
private_key_der = bytes.fromhex(private_key_hex) |
|
|
|
# these below will only work for the browser that acquired the subscription info. You will need to extract those from our console OR the db. |
|
|
|
|
|
|
|
private_key_base64 = base64.b64encode(private_key_der).decode() |
|
|
|
# https://fcm.googleapis.com/fcm/send/eqNQV7MVPic:APA91bGrIMxqz3sQ4wboUkmZithJHMAdrNgjm6BYcIGmgJozgEGeg23JsXLlNpnKwzBCmUXh1ciHmE_3wZakHX-Rho5f9Xovc28nun4nH7w4BMoYzX27pOw_pC4FtfAkBQaQ-8jm36jf |
|
|
|
# BDo2fIIN7qoA5bOVXdrHATZUSPHY7030V8PKW1mIHAZHDAxS-p6RggVeI7IZoi3bGxpR713RYY8H8vu-lX5LY1w |
|
|
|
# sVR_s8J4JHv3h4ZmvemL5w |
|
|
|
|
|
|
|
subscription_info = { |
|
|
|
"endpoint": "https://fcm.googleapis.com/fcm/send/eqNQV7MVPic:APA91bGrIMxqz3sQ4wboUkmZithJHMAdrNgjm6BYcIGmgJozgEGeg23JsXLlNpnKwzBCmUXh1ciHmE_3wZakHX-Rho5f9Xovc28nun4nH7w4BMoYzX27pOw_pC4FtfAkBQaQ-8jm36jf", |
|
|
@ -45,6 +42,26 @@ if len(sys.argv) > 1: |
|
|
|
now = datetime.datetime.now().isoformat() |
|
|
|
data = json.dumps({"title": "test", "message": f"Message at {now}"}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Private parts |
|
|
|
|
|
|
|
# if you've got hex |
|
|
|
#private_key_hex = "308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420ac868a9588a69ec9626db857caae42b0d654288abf73b0d8f1a6b43fff093508a1440342000466da453c1e793d7e21ab63b334e80f96715aa97e578639b5fe8092f8752fa6e1f9182324846c70bf1a3480411ba787e652be8049a36a14294681f745c4c4c4f7" |
|
|
|
#private_key_der = bytes.fromhex(private_key_hex) |
|
|
|
#private_key_base64 = base64.b64encode(private_key_der).decode() |
|
|
|
|
|
|
|
# if you've got base64 |
|
|
|
private_key_base64 = "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgtMWLjpglbBDApUkuWjhJhdik3zzpPFjwC5IO9J8v25uhRANCAARWOqEBw7A01F44GqE9SEX1FX7qcHCv9eBsbgGwcF/XQK48o+WGv38Q4g9o+W2WvakiNjFCDa6cePY1+ZyEnbca" |
|
|
|
|
|
|
|
# set private_key_base64 if supplied from arg 2 |
|
|
|
if len(sys.argv) > 2: |
|
|
|
private_key_base64 = sys.argv[2] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
result = webpush(subscription_info, |
|
|
|
data, |
|
|
|