Send Mass Push Notifications By Platform - Python

Source Code Option 1: http.client

  

import http.client

conn = http.client.HTTPSConnection("send.pushnotificationapi.com")

payload = "api_key=YOUR-API-KEY&msg_title=YOUR-MESSAGE&destination_url=YOUR-URL&platform=Android-iOS-Windows"

headers = {
    'content-type': "application/x-www-form-urlencoded",
    'cache-control': "no-cache"
    }

conn.request("POST", "/v1/push/send_by_platform", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))


 

Source Code Option 2: requests

  
import requests

url = "https://send.pushnotificationapi.com/v1/push/send_by_platform"

payload = "api_key=YOUR-API-KEY&msg_title=YOUR-MESSAGE&destination_url=YOUR-URL&platform=Android-iOS-Windows"
headers = {
    'content-type': "application/x-www-form-urlencoded",
    'cache-control': "no-cache"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)