I made this some time ago, it basicly uploads the code to www.pastebin.com
Note that this can be done with alot of websites but the variables just have a different name
SIMPLE VERSION:
This one just uploads the file and dat's it.
First make a simple form with a few textboxes and a button:
![[Image: muniuTEcId.png]](http://i.nowfollow.nl/muniuTEcId.png)
then double click the button. All we do is send an array to a website and wait for the response. Here are the variables that you define:
you devkey can be found here (you need a pastebin account): http://pastebin.com/api#1
textbox1.text will be the text that gets uploaded and textbox2.text is the title of the paste. The expiration codes can be found here: http://pastebin.com/api#6 the current one doesn't expire ("N" .. Never). Don't change the option: "paste".
now we gotta send that shit to www.pastebin.com, for this we use a WebClient (its in the System.Net namespace)
now "bytes" will contain a byte array which we need to convert to a string:
now "response" will contains either an error or the link to the paste, to check if its an error just use:
And there you go, now you can check the link and see if its working!
Here's my end result:
I added a "Raw file" button so it shows the raw file .. kinda pointless but whatever 
ADVANCED VERSION:
this version can upload a paste to an account, make it private and format it.
so we just copy and paste the stuff we have from the simple version, add 2 extra textboxes to the form which will be the username and password and we add a combobox for private/public.
Note: I replaced the bytes to text part with this function:
First the login part, we need to get a "api_user_key" which we can get the same way as posting it. We need 3 things:
then we send it again and wait for the response:
again check for errors:
if it doesn't return an error then:
now when you send the data it will be uploaded to that account
for formatted code we just add:
codes can be found here: http://pastebin.com/api#5
And the last one: Private/public pastes which is also pretty easy:
For this you need 2 options in your combobox, "Private" and "Public". 
edit:
Here's the endresult for the advanced one:
Note that this can be done with alot of websites but the variables just have a different name
SIMPLE VERSION:
This one just uploads the file and dat's it.
First make a simple form with a few textboxes and a button:
![[Image: muniuTEcId.png]](http://i.nowfollow.nl/muniuTEcId.png)
then double click the button. All we do is send an array to a website and wait for the response. Here are the variables that you define:
Code:
System.Collections.Specialized.NameValueCollection Data
= new System.Collections.Specialized.NameValueCollection();
Data["api_paste_name"] = textBox2.Text;
Data["api_paste_expire_date"] = "N";
Data["api_paste_code"] = textBox1.Text;
Data["api_dev_key"] = "YOUR DEV KEY HERE";
Data["api_option"] = "paste";you devkey can be found here (you need a pastebin account): http://pastebin.com/api#1
textbox1.text will be the text that gets uploaded and textbox2.text is the title of the paste. The expiration codes can be found here: http://pastebin.com/api#6 the current one doesn't expire ("N" .. Never). Don't change the option: "paste".
now we gotta send that shit to www.pastebin.com, for this we use a WebClient (its in the System.Net namespace)
Code:
WebClient wb = new WebClient();
byte[] bytes = wb.UploadValues( "http://pastebin.com/api/api_post.php", Data );now "bytes" will contain a byte array which we need to convert to a string:
Code:
string response;
using ( MemoryStream ms = new MemoryStream( bytes ) )
using ( StreamReader reader = new StreamReader( ms ) )
response = reader.ReadToEnd();now "response" will contains either an error or the link to the paste, to check if its an error just use:
Code:
if ( response.StartsWith( "Bad API request" ) )
{
// do whatever you want when there's something wrong with the paste
}
else
{
// do the stuff if the paste is correct
textBox3.Text = response;
}And there you go, now you can check the link and see if its working!
Here's my end result:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace Pastebin
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
textBox3.Enabled = false;
textBox3.ReadOnly = true;
}
private void button1_Click( object sender, EventArgs e )
{
Upload:
System.Collections.Specialized.NameValueCollection Data
= new System.Collections.Specialized.NameValueCollection();
Data["api_paste_name"] = textBox2.Text;
Data["api_paste_expire_date"] = "N";
Data["api_paste_code"] = textBox1.Text;
Data["api_dev_key"] = "4dd29af09faf6e39abcae2c910ad8f2e";
Data["api_option"] = "paste";
WebClient wb = new WebClient();
byte[] bytes = wb.UploadValues( "http://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" ) )
{
if ( MessageBox.Show( "Failed to upload!", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error ) == DialogResult.Retry )
goto Upload;
}
else
{
if ( checkBox1.Checked )
response = "http://pastebin.com/raw.php?i=" + response.Substring( 20 );
Clipboard.SetText( response );
textBox3.Text = response;
textBox3.Enabled = true;
MessageBox.Show( "Succesfully uploaded! \r\nLink copied to clipboard.", "Success!" );
}
}
}
}
ADVANCED VERSION:
this version can upload a paste to an account, make it private and format it.
so we just copy and paste the stuff we have from the simple version, add 2 extra textboxes to the form which will be the username and password and we add a combobox for private/public.
Note: I replaced the bytes to text part with this function:
Code:
string ResponseText( byte[] bytes )
{
using ( MemoryStream ms = new MemoryStream( bytes ) )
using ( StreamReader reader = new StreamReader( ms ) )
return reader.ReadToEnd();
}First the login part, we need to get a "api_user_key" which we can get the same way as posting it. We need 3 things:
Code:
Data["api_user_name"] = textBox4.Text;
Data["api_user_password"] = textBox5.Text;
Data["api_dev_key"] = "YOUR DEV KEY";then we send it again and wait for the response:
Code:
bytes = wb.UploadValues( "http://pastebin.com/api/api_login.php", Data );
response = ResponseText( bytes );again check for errors:
Code:
if ( response.StartsWith( "Bad API request" ) )if it doesn't return an error then:
Code:
Data["api_user_key"] = response;now when you send the data it will be uploaded to that account

for formatted code we just add:
Code:
Data["api_paste_format"] = "FORMAT CODE HERE";And the last one: Private/public pastes which is also pretty easy:
Code:
Data["api_paste_private"] = comboBox2.SelectedItem.ToString().ToLower() == "private" ? "1" : "0";
edit:
Here's the endresult for the advanced one:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace Pastebin
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
textBox3.Enabled = false;
textBox3.ReadOnly = true;
}
string ResponseText( byte[] bytes )
{
using ( MemoryStream ms = new MemoryStream( bytes ) )
using ( StreamReader reader = new StreamReader( ms ) )
return reader.ReadToEnd();
}
private void button1_Click( object sender, EventArgs e )
{
Upload:
System.Collections.Specialized.NameValueCollection Data
= new System.Collections.Specialized.NameValueCollection();
WebClient wb = new WebClient();
string response;
byte[] bytes;
if ( textBox4.Text != "Username" && textBox5.Text != "Password" )
{
Data["api_user_name"] = textBox4.Text;
Data["api_user_password"] = textBox5.Text;
Data["api_dev_key"] = "4dd29af09faf6e39abcae2c910ad8f2e";
bytes = wb.UploadValues( "http://pastebin.com/api/api_login.php", Data );
response = ResponseText( bytes );
if ( response.StartsWith( "Bad API request" ) )
{
if ( MessageBox.Show( "Login failed, do you want to upload it as guest?", "Login failed", MessageBoxButtons.YesNo, MessageBoxIcon.Error ) == DialogResult.Yes )
{
Data["api_user_name"] = textBox4.Text;
Data["api_user_password"] = textBox5.Text;
goto SkipLogin;
}
else
return;
}
Data["api_user_key"] = response;
}
SkipLogin:
Data["api_paste_private"] = comboBox2.SelectedItem.ToString().ToLower() == "private" ? "1" : "0";
Data["api_paste_name"] = textBox2.Text;
Data["api_paste_expire_date"] = "N";
Data["api_paste_code"] = textBox1.Text;
Data["api_option"] = "paste";
bytes = wb.UploadValues( "http://pastebin.com/api/api_post.php", Data );
response = ResponseText( bytes );
if ( response.StartsWith( "Bad API request" ) )
{
if ( MessageBox.Show( "Failed to upload!\r\n" + response, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error ) == DialogResult.Retry )
goto Upload;
}
else
{
if ( checkBox1.Checked )
response = "http://pastebin.com/raw.php?i=" + response.Substring( 20 );
Clipboard.SetText( response );
textBox3.Text = response;
textBox3.Enabled = true;
MessageBox.Show( "Succesfully uploaded! \r\nLink copied to clipboard.", "Success!" );
}
}
}
}(08-10-2011, 12:58)Pozzuh Wrote:Se7en Wrote:Stealed, from cod4 mod ...look who's talking
[Release] Old School Mod v2.2
[Release] Scroll menu




![[Image: lQDUjba.jpg]](http://i.imgur.com/lQDUjba.jpg)

