public UploadResult PushFile(Stream stream, string fileName) { NameValueCollection headers = CreateAuthenticationHeader(Config.UserAPIKey, ""); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("device_iden", Config.CurrentDevice.Key); args.Add("type", "file"); UploadResult result = UploadData(stream, "https://api.pushbullet.com/api/pushes", fileName, arguments: args, headers: headers); PushbulletResponsePush push = JsonConvert.DeserializeObject <PushbulletResponsePush>(result.Response); if (push != null) { result.URL = "https://www.pushbullet.com/pushes?push_iden=" + push.iden; } return(result); }
private string Push(string pushType, string valueType, string value, string title) { NameValueCollection headers = CreateAuthenticationHeader(Config.UserAPIKey, ""); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("device_iden", Config.CurrentDevice.Key); args.Add("type", pushType); args.Add("title", title); args.Add(valueType, value); if (valueType != "body") { if (pushType == "link") { args.Add("body", value); } else { args.Add("body", "Sent via ShareX"); } } string response = SendRequest(HttpMethod.POST, apiSendPushURL, args, headers); if (response == null) { return(null); } PushbulletResponsePush push = JsonConvert.DeserializeObject <PushbulletResponsePush>(response); if (push != null) { return(wwwPushesURL + "?push_iden=" + push.iden); } return(null); }
private string Push(string pushType, string valueType, string value, string title) { NameValueCollection headers = CreateAuthenticationHeader(Config.UserAPIKey, ""); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("device_iden", Config.CurrentDevice.Key); args.Add("type", pushType); args.Add("title", title); args.Add(valueType, value); string response = SendRequest(HttpMethod.POST, "https://api.pushbullet.com/api/pushes", args, headers: headers); PushbulletResponsePush push = JsonConvert.DeserializeObject <PushbulletResponsePush>(response); if (push != null) { return("https://www.pushbullet.com/pushes?push_iden=" + push.iden); } return(null); }
public UploadResult PushFile(Stream stream, string fileName) { NameValueCollection headers = CreateAuthenticationHeader(Config.UserAPIKey, ""); Dictionary <string, string> pushArgs, upArgs = new Dictionary <string, string>(); upArgs.Add("file_name", fileName); string uploadRequest = SendRequest(HttpMethod.POST, apiRequestFileUploadURL, upArgs, headers); if (uploadRequest == null) { return(null); } PushbulletResponseFileUpload fileInfo = JsonConvert.DeserializeObject <PushbulletResponseFileUpload>(uploadRequest); if (fileInfo == null) { return(null); } pushArgs = upArgs; upArgs = new Dictionary <string, string>(); upArgs.Add("awsaccesskeyid", fileInfo.data.awsaccesskeyid); upArgs.Add("acl", fileInfo.data.acl); upArgs.Add("key", fileInfo.data.key); upArgs.Add("signature", fileInfo.data.signature); upArgs.Add("policy", fileInfo.data.policy); upArgs.Add("content-type", fileInfo.data.content_type); UploadResult uploadResult = UploadData(stream, fileInfo.upload_url, fileName, "file", upArgs); if (uploadResult == null) { return(null); } pushArgs.Add("device_iden", Config.CurrentDevice.Key); pushArgs.Add("type", "file"); pushArgs.Add("file_url", fileInfo.file_url); pushArgs.Add("body", "Sent via ShareX"); string pushResult = SendRequest(HttpMethod.POST, apiSendPushURL, pushArgs, headers); if (pushResult == null) { return(null); } PushbulletResponsePush push = JsonConvert.DeserializeObject <PushbulletResponsePush>(pushResult); if (push != null) { uploadResult.URL = wwwPushesURL + "?push_iden=" + push.iden; } return(uploadResult); }