Send Mass Push Notifications By Tag - Java

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&tag=YOUR-TAG"

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

conn.request("POST", "/v1/push/send_by_tag", 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_tag"

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

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

print(response.text)