Send a message with #PushBullet using c#
Pushbullet is an iOS / Android and Web based app, that is used for automated messaging. It’s pretty easy to use from within C#, here’s an example;
* curl –header ‘Access-Token: <your_access_token_here>’ \
–header ‘Content-Type: application/json’ \
–data-binary ‘{“body”:”Space Elevator, Mars Hyperloop, Space Model S (Model Space?)”,”title”:”Space Travel Ideas”,”type”:”note”}’ \
–request POST \
https://api.pushbullet.com/v2/pushes
*/var message = new
{
body = “Space Elevator, Mars Hyperloop, Space Model S (Model Space?)”,
title = “Space Travel Ideas”,
type = “note”
};
WebClient wc = new WebClient();
wc.Headers[“Access-Token”] = “o.xxxxxxxxxxxxxx”;
wc.Headers[“Content-Type”] = “application/json”;
var strPayload = JsonConvert.SerializeObject(message);
var strResponse = wc.UploadString(“https://api.pushbullet.com/v2/pushes”, strPayload);/*
{
“active”: true,
“iden”: “xxxxxxx”,
“created”: 1512656152.566,
“modified”: 1512656152.5928,
“type”: “note”,
“dismissed”: false,
“direction”: “self”,
“sender_iden”: “ujvhvGp18iy”,
“sender_email”: “xxxx@hotmail.com”,
“sender_email_normalized”: “xxxx@hotmail.com”,
“sender_name”: “xxxx xxxx”,
“receiver_iden”: “ujvhvGp18iy”,
“receiver_email”: “xxxx@hotmail.com”,
“receiver_email_normalized”: “xxx@hotmail.com”,
“title”: “Space Travel Ideas”,
“body”: “Space Elevator, Mars Hyperloop, Space Model S (Model Space?)”
}
*/
The above code requires the NUNIT packageĀ Install-Package Newtonsoft.Json, and you’ll need an access token from pushbullet under your account > Settings