1

I'm looking for a way to submit a post to pastie.org, or pastebin.com from within my C# app, i know ill have to use some sort of http post but im looking for specific examples..

codemst
  • 31
  • 2
  • 5
  • @George, ive tried using some http poster class's, but none of them seem to work, or im using them wrong. / sending the data incorrectly – codemst Dec 31 '09 at 23:16

2 Answers2

6

I just wrote a simple PasteBin client in C#.

You can use it as follows:

        string apiKey = "<your api key>";
        var client = new PasteBinClient(apiKey);

        // Optional; will publish as a guest if not logged in
        client.Login(userName, password);

        var entry = new PasteBinEntry
            {
                Title = "PasteBin client test",
                Text = "Console.WriteLine(\"Hello PasteBin\");",
                Expiration = PasteBinExpiration.OneDay,
                Private = true,
                Format = "csharp"
            };

        string pasteUrl = client.Paste(entry);
        Console.WriteLine("Your paste is published at this URL: " + pasteUrl);

You can obtain your API key on this page (you need to be logged in).

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
1

It might be worth your while to check and monitor the HTTP GET/POST's when using your browser to post sample code/text and intercept the data and find out..Use Wireshark or HTTPWatch. This should give you an idea on what is expected in the HTTP's POST. You would need to set the content-length in the HTTP header to the actual length of the code being submitted, have a look here and here and here.

Wishing you a happy and peaceful 2010. Hope this helps,

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
t0mm13b
  • 34,087
  • 8
  • 78
  • 110