public Uri Send(string Body, string Subj = "", string Private = "0", string Expire = "N", string Format = "none")
{
if (string.IsNullOrEmpty(Body.Trim())) throw new ArgumentNullException("Body", "Cannot have an empty paste.");
var IQuery = new NameValueCollection()
{
{ "api_dev_key", IDevKey },
{ "api_option", "paste" },
{ "api_paste_code", Body }
};
//IQuery.Add("api_paste_private", "0");
if (!string.IsNullOrEmpty(Private.Trim())) IQuery.Add("api_paste_private", Private);
//IQuery.Add("api_paste_name", Subj);
if (!string.IsNullOrEmpty(Subj.Trim())) IQuery.Add("api_paste_name", Subj);
//IQuery.Add("api_paste_expire_date", "N");
if (!string.IsNullOrEmpty(Expire.Trim())) IQuery.Add("api_paste_expire_date", Expire);
//IQuery.Add("api_paste_format", Format);
if (!string.IsNullOrEmpty(Format.Trim())) IQuery.Add("api_paste_format", Format);
//IQuery.Add("api_user_key", IUserKey);
if (!string.IsNullOrEmpty(UserKey.Trim()))
{
IQuery.Add("api_user_key", UserKey);
}
else if (Private == "2")
{
throw new ArgumentException("Cannot have a private paste while not logged in.", "Private");
}
using (var IClient = new WebClient())
{
string IResponse = Encoding.UTF8.GetString(IClient.UploadValues(IPostURL, IQuery));
Uri isValid = null;
if (!Uri.TryCreate(IResponse, UriKind.Absolute, out isValid))
{
throw new WebException("An error occurred while making the paste.", WebExceptionStatus.SendFailure);
}
return isValid;
}
}