Sunday, June 20, 2010

.NET API for PasteHTML

PasteHTML is a website which lets you upload and share HTML pages. It's free, anonymous and without registration. The uploaded pages should stay online forever.

The only drawback is that you can't edit or delete your uploaded pages in an easy way yet. It is ad free, but I guess there will be some advertisements in the future when hosting costs increase.

You can make a POST request to upload a page through their public API. I made an API for .NET which encapsulates building the url, making the request and parsing the response. This API makes uploading pages to PasteHtml through your own website or program child's play.

Example

   1:  PasteHtmlClient client = new PasteHtmlClient();
   2:   
   3:  PasteHtmlRequest req = new PasteHtmlRequest()
   4:  {
   5:       InputType = PasteHtmlInputType.Html,
   6:       Text = @"<div class='box'> 
   7:                <h3>The standard Lorem Ipsum passage, used since the 1500s</h3> 
   8:                <p>Lorem ipsum dolor sit amet, consectetur..</p>
   9:                </div>"
  10:  };
  11:   
  12:  PasteHtmlResponse resp = client.PasteHtml(req);            
  13:              
  14:  System.Console.WriteLine(resp.Url);
  15:  System.Console.ReadKey();           

In this example the PasteHtmlResponse.Url property returned http://pastehtml.com/view/19tfe0n.html.

Assemblies, source and your opinion!

You can download the API's Alpha version here. Play with it, take a look at the source and let me know what you think!

Update (22/10/2010): Fixed the download.
Update (24/07/2011): The project is now on Github!

2 comments: