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 = SendRequestMultiPart(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); }
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 = SendRequestMultiPart(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 = SendRequestFile(fileInfo.upload_url, stream, 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 = SendRequestMultiPart(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); }