using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.IO;
public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
System.Collections.Specialized.NameValueCollection Data = new System.Collections.Specialized.NameValueCollection();
Data["api_paste_name"] = "ClipboardFusion Paste";
// Defaults to 1 day, can be changed. See Pastebin API
Data["api_paste_expire_date"] = "1D";
Data["api_paste_code"] = text;
// 0 = public, 1 = unlisted, 2 = private
Data["api_paste_private"] = "1";
Data["api_dev_key"] = "<API Key>";
Data["api_option"] = "paste";
using( WebClient wb = new WebClient() )
{
byte[] bytes = wb.UploadValues( "https://pastebin.com/api/api_post.php", Data );
string response;
using ( MemoryStream ms = new MemoryStream( bytes ) )
using ( StreamReader reader = new StreamReader( ms ) )
response = reader.ReadToEnd();
if ( response.StartsWith( "Bad API request" ) )
{
BFS.Dialog.ShowMessageInfo("Failed to upload. Response: " + response);
return text;
}
else
{
BFS.Dialog.ShowMessageInfo("Sent to Pastebin. URL in clipboard.");
return response;
}
}
}
}