Jared Madurai

Jared Madurai

  • NA
  • 9
  • 469

PushBullet notification to more than one person

Sep 15 2019 11:54 AM
ive coded the notification too be sent out like this, do i have to use the api keys to every account i want to send a notification too or is there a better aproach  
 
 
 
 
String apiKey = "o.2OU1tt3SygeQxzc7vUsgEV7rdp*******";
String type = "note", title = "Job Card Notification ", body = userList + " has been assigned a job card, please sign into the system to view details";
byte[] data = Encoding.ASCII.GetBytes(String.Format("{{ \"type\": \"{0}\", \"title\": \"{1}\", \"body\": \"{2}\" }}", type, title, body));
var request = System.Net.WebRequest.Create("https://api.pushbullet.com/v2/pushes") as System.Net.HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/json";
request.Credentials = new System.Net.NetworkCredential(apiKey, "");
request.ContentLength = data.Length;
String responseJson = null;
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(data, 0, data.Length);
requestStream.Close();
}
using (var response = request.GetResponse() as System.Net.HttpWebResponse)
{
using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
{
responseJson = reader.ReadToEnd();
}
}